tags:

views:

36

answers:

3

Hello, We have a Oracle 9i database and OrderDetails table which has a column to store binary data for product images. These images can be viewed only using a 3rd party tool. I have no idea which 3rd party tool. and I have no idea of the format of the image.

Is there anyway from the binary data we can find what format is the image?

Thanks

+2  A: 

file or libmagic is a good place to start.

Matthew Flaschen
A: 

Yeah, read about headers of JPG, PNG, GIF and other popular image formats and try to recognize their headers in your data.

Bartosz Wójcik
Actually don't do any of that. That's re-inventing the wheel. Look for a 3rd party tool... It's not even a really interesting problem - just lots of gruntwork gathering patterns to match different image formats against.
Cam
Actually do that and learn a thing or two about file formats.
Bartosz Wójcik
+1  A: 

From your description it isn't clear whether the third-party tool is needed to access the data or to display it. It is entirely probable the data is simply JPG, BMP or PNG and the tool is basically an SQL frontend. To verify this try to write out the binary data to a file (being careful to tell your program it's binary data) and then try to open it with a standard image tool. A decent image editor will ignore the extension and sniff the data to get the format.

If you verify it really is a standard binary image you have two options:

  1. Batch convert to JPEG, saving yourself the effort of learning the format.
  2. Find a tool that tells you the format (there are many including Imagemagick identify and even
    online tools)
SpliFF