0

I have a SQL Server 2005 table with an IMAGE column. The database was originally created in SQL Server 2000.

I want to extract the 900 or so images. The images were created by some old off the shelf ID card software called CardFive, and are created in the software by using TWAIN to create the image directly from a scanner. The user scans the image and it just appears in the ID card software. They are then stored in SQL Server by the software. The problem is, no image file is ever created as far as far I can tell and so I don't know what format the software creates the images in.

I have tried using BCP to extract an image as a test, and have tried giving the filename all sorts of extensions .gif, .jpg, .jpeg, .bmp. However, each time the resulting file cannot be opened.

Does anyone have any ideas on how I could crack this one?

Thanks in advance Jonathan

  • You could try `Image.RawFormat` http://msdn.microsoft.com/en-us/library/system.drawing.image.rawformat.aspx in .net, the `file` command on Linux or even `Identify` from ImageMagick http://www.imagemagick.org/script/identify.php assuming the data is stored in some kind of image format with a known magic number. – Liesel Aug 04 '16 at 01:14
  • Thanks. I have now managed to extract some of the images by using .net Image.FromStream instead of BCP. For some of the images this works. However for others, I get "parameter is not valid", most likely because .net doesnt recognise the data as a valid image..... not sure why. I am guessing that these were stored with an offset, which I could deal with if I knew what the offset was, but I don't. Any thoughts on how to deal with this gratefully received. – Jonathan Shields Aug 04 '16 at 14:36
  • Maybe save the bytes to a file then point Identify at it - ImageMagick supports many more formats than .net. BTW for BCP you probably need a format file to stop it writing the column data size into the exported file http://stackoverflow.com/questions/4056050/script-to-save-varbinary-data-to-disk – Liesel Aug 05 '16 at 01:50
  • There will be an identifier at the start of the data. If it's old it's probably in .TIF format. Post a link to a file(extension does not matter for me) and I'll take a gander. – Trey Mar 24 '17 at 13:06

0 Answers0