Mogrify destroys/obscures TIFF EXIF data?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
spamcop99

Mogrify destroys/obscures TIFF EXIF data?

Post by spamcop99 »

I apologize for my ignorance and if this is the wrong place to post this inquiry. I've been using Timothy Armes' LR/Mogrify plugin:

http://www.timothyarmes.com/lrmogrify.php?sec=main

which uses (not surprisingly) mogrify to manipulate images after they've been Exported from Adobe Photoshop Lightroom. In order to preserve best image quality and receive the full benefit of using ImageMagick, it's preferred to Export as a TIFF and then pass it to mogrify for all subsequent optimizations (e.g., colorspace conversions, resizing, sharpening, etc.).

The problem I (and some others) have witnessed is that the mogrify command appears to be having problems reading the EXIF data out of the initially exported TIFF and thus cannot transfer it to any future file conversion (e.g., JPEG).

I've done several different tests using mogrify to do a variety of conversions and optimizations, but to strip it down to the simplest example, suppose I Export a TIFF directly from Lightroom with no subsequent use of mogrify. That TIFF file contains EXIF data which is readily viewable in several different imaging apps (e.g., IrfanView, ACDSee, Photoshop, etc.). However, if I take that TIFF and do nothing other than run the mogrify command against it (with no options), the resultant TIFF no longer has the EXIF data (or if it's there, it can't be read by the aforementioned apps). The same set of steps applied to initially Exported JPEG (instead of TIFF) out of Lightroom does NOT result in a problem - the EXIF data is still readily available even if I subsequently run the mogrify command against the file with no options. Hence the reason why I believe this issue is localized to TIFF files.

The only reason I care about this is because I like to upload my post-processed JPEGs to the web and have the ability to display full EXIF data. Using the workflow above (which I otherwise LOVE) is not getting me the desired results and I'd like to know if there's a solution to my problem.

I've tried this on these two versions of ImageMagick:

ImageMagick-6.3.7-9-Q16-windows-dll
ImageMagick-6.3.8-2-Q16-windows-dll

Both of these were run on Windows XP Pro SP2.


Many thanks in advance.

Cheers,
Dylan
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by magick »

Post a URL to a sample TIFF image we can download and reproduce the problem. More than likely we will have a fix for the problem within a few days.
spamcop99

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by spamcop99 »

Thanks so much for the prompt reply. I will get examples uploaded later this evening and post back with the links.

Cheers,
Dylan
spamcop99

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by spamcop99 »

I have uploaded three files within a zip to:

http://www.yousendit.com/transfer.php?a ... eeff485d2d

File #1

_1190872_g4a.tif - ran with LR/Mogrify plugin and no other conversions/options selected. In effect, it ran:

mogrify.exe -virtual-pixel mirror _1190872_g4a.tif

Result: EXIF info is NOT viewable through imaging apps.

File #2

_1190872_g4b.tif - Basic Lightroom Export to TIFF (no mogrify used).

Result: EXIF data is viewable through imaging apps.

File #3

_1190872d.jpg - did a Lightroom Export to TIFF using the LR/Mogrify plugin and selected to have the file converted to JPEG via mogrify options.

Result: EXIF data is NOT viewable through imaging apps.

Also, please refer back to my initial post where I described the simple test that I conducted. In that, I did nothing but take a Lightroom Exported EXIF viewable TIFF file and run the mogrify.exe binary against it from the command line with no options. The results are identical to those of File #1 above.

Thanks again for your efforts and please let me know if you need additional information.

Cheers,
Dylan
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by magick »

EXIF data is stored in a custom directory within TIFF. We will need to investigate how to read/write this custom directory and add a patch to ImageMagick. There is currently no ETA when we will have this problem fixed.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by magick »

ImageMagick 6.3.8-3 Beta reads the TIFF EXIF properties, however, there currently is no mechanism in the libtiff delegate library to write EXIF data. If you feel otherwise, please post some sample libtiff API calls we can use to write the EXIF data to the TIFF image file.
spamcop99

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by spamcop99 »

Is there a Windows Binary release download section for Beta versions (I see it in the Source downloads) or should I just wait until this gets incorporated? I'll let Tim respond to your last question, but the issue for me has been getting the EXIF data to transfer to the converted image format. For me at least, that's JPEG. I could be wrong, but I doubt many folks would use mogrify to go from TIFF to TIFF, and if so, whether they cared if the EXIF data came along for the ride!

Thx again,
Dylan
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by magick »

The current ImageMagick release should properly support EXIF for JPEG.

ImageMagick 6.3.8-3 is scheduled for release within a week.
spamcop99

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by spamcop99 »

The current binary release does support (and maintain) EXIF data for doing JPEG to JPEG conversions. But my hope is that by enabling the reading of EXIF data from the TIFF in your new release, that EXIF data can/will be written through to the final JPEG upon conversion with mogrify. That's kinda what started all the fuss in the first place. :D
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by magick »

ImageMagick does some rudimentary parsing of some profiles but in most cases just reads a profile as a blob and deposits it in the output image format. Every profile except EXIF is stored within TIFF as a blob. EXIF is stored in a separate custom directory. Its possible the separate custom directory can be read/written as a blob but currently we retrieve the EXIF tags with separate TiffGetField() calls and report them with the identify program. However, these tags are not reassembled into an EXIF blob as required by the JPEG format. If you check Google and enter something like "+write +EXIF +libtiff" you will find quite a few folks that are disappointed that libtiff (the defacto TIFF standards delegate library) does not support writing TIFF EXIF data. TIFF has always been problematic because there are so many private tags created by different companies (such as Kodak) and different software packages. EXIF is a private tag and apparently is not part of the official Adobe TIFF standard.
spamcop99

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by spamcop99 »

Thank you for all the helpful info. Would something like this be of assistance:

http://www.atalasoft.com/products/dotim ... /exif.html

I'm not a programmer so I have no clue but it looked like it may be relevant...

Thx again,
Dylan
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by magick »

Your article was not helpful since it does not address how to read/write EXIF with the libtiff delegate library which is what ImageMagick uses to deal with TIFF images. ImageMagick is cross platform so any solution we come up with needs to be able to be used in any environment whether it be Linux, BSD, Mac OS X, Windows, or VMS.
JoaCHIP
Posts: 37
Joined: 2004-12-21T04:22:18-07:00
Location: Copenhagen

Re: Mogrify destroys/obscures TIFF EXIF data?

Post by JoaCHIP »

Confirmed

Exif is missing when converting from TIFF to JPEG: Confirmed with version "6.3.6 02/13/08" and "6.5.2-10 2009-06-07" under FreeBSD. The new version even spits out the following error message if the TIFF is coming from Photoshop CS2:

Code: Select all

convert -quality 90 saved_with_photoshop.tif saved_with_im.jpg
convert: saved_with_photoshop.tif: unknown field with tag 40961 (0xa001) encountered. `TIFFReadCustomDirectory' @ tiff.c/TIFFWarnings/525.
Why I would like this feature

The utility "dcraw" that unix users use to convert raw images from cameras can only output either TIFF (with EXIF data) or the rather crude/stupid PPM format (which throws away EXIF and any other kind of meta data.)

TIFF seems to be the only intermediate format currently usable because dcraw doesn't output PNG files or JPEG files directly. Of course it's probably possible to do some funky script wizardry to solve this, but it would just be really nice and handy if ImageMagick could preserve EXIF from TIFF files on it's own.
Post Reply