Page 1 of 1

Problems when converting TIFF files that contain tag 37724

Posted: 2011-11-09T11:17:14-07:00
by rwruck
Hi,

there seems to be a problem when converting TIFF files when the source contains the Photoshop ImageSourceData tag (37724).
I've used a command line like this (IM 6.7.2.0) to compress a TIFF file:

Code: Select all

convert -compress JPEG source.tif destination.tif
Reading the input file shows the usual warnings:

Code: Select all

source.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/707
That's not a problem so far, but when writing the output file, there are errors:

Code: Select all

destination.tif: Unknown tag 37724. `TIFFSetField' @ error/tiff.c/TIFFErrors/497
The output file is written BUT it does not contain the 37724 tag AND convert exits with code 1 which indicates a failure.
Looking at tiff.c, there's the following code which seems to be intended for handling this tag:

Code: Select all

    if (LocaleCompare(name,"tiff:37724") == 0)
      (void) TIFFSetField(tiff,37724,(uint32)GetStringInfoLength(profile),
        GetStringInfoDatum(profile));
This does not work, because 37724 is a custom tag. You'd have to register it using TIFFSetTagExtender as outlined here: http://www.asmail.be/msg0054585832.html

I'd assume that the declaration of the ImageSourceData tag would be something like

Code: Select all

{ 37724, -1, -1, TIFF_UNKNOWN, FIELD_CUSTOM, 1, 1, "ImageSourceData" }

Re: Problems when converting TIFF files that contain tag 377

Posted: 2011-11-09T11:43:16-07:00
by magick
We can reproduce the problem you posted and will get a patch into ImageMagick 6.7.3-5 Beta within a few days. Thanks.

Can you post a URL to one of your TIFF images with the 37724 tag so we can test our solution?

Re: Problems when converting TIFF files that contain tag 377

Posted: 2011-11-09T12:41:52-07:00
by rwruck
Thanks for the quick reply.

Here is an image: http://www.rw-it.net/public/37724/test.tiff

Here is a patch I made that works for me: http://www.rw-it.net/public/37724/patch ... iff.c.diff

Re: Problems when converting TIFF files that contain tag 377

Posted: 2011-11-09T18:22:47-07:00
by magick
We have the patch in ImageMagick 6.7.3-5 Beta and the Subversion trunk. For now we treat the 37724 tag as a binary blob. In the future, we'll add code to decode the blob and extract the metadata.