Pyramidal TIFF doesn't correctly set TIFFTAG_SUBFILETYPE
Posted: 2011-11-22T21:16:53-07:00
Version: 6.7.3, svn r6051
OS: Linux
Writing a PTIF with convert sets the FILETYPE_PAGE flag on every image within the file, as though the TIFF is a multi-page image. It should be setting no flags on the first (full-sized) image, and FILETYPE_REDUCEDIMAGE on subsequent images.
This patch fixes the problem for me:
Result:
OS: Linux
Writing a PTIF with convert sets the FILETYPE_PAGE flag on every image within the file, as though the TIFF is a multi-page image. It should be setting no flags on the first (full-sized) image, and FILETYPE_REDUCEDIMAGE on subsequent images.
Code: Select all
$ convert ~/small.ppm -define tiff:tile-geometry=256x256 ~/small.ptif
$ tiffinfo small.ptif
TIFF Directory at offset 0x300008 (3145736)
Subfile Type: multi-page document (2 = 0x2)
Image Width: 1000 Image Length: 1000
Tile Width: 256 Tile Length: 256
[...]
TIFF Directory at offset 0x3c021a (3932698)
Subfile Type: multi-page document (2 = 0x2)
Image Width: 500 Image Length: 500
Tile Width: 256 Tile Length: 256
[...]
TIFF Directory at offset 0x3f03cc (4129740)
Subfile Type: multi-page document (2 = 0x2)
Image Width: 250 Image Length: 250
Tile Width: 256 Tile Length: 256
[...]
Code: Select all
Index: coders/tiff.c
===================================================================
--- coders/tiff.c (revision 6051)
+++ coders/tiff.c (working copy)
@@ -2154,7 +2154,6 @@
Write pyramid-encoded TIFF image.
*/
write_info=CloneImageInfo(image_info);
- *write_info->magick='\0';
write_info->adjoin=MagickTrue;
status=WriteTIFFImage(write_info,GetFirstImageInList(images));
images=DestroyImageList(images);
@@ -3081,7 +3080,8 @@
chromaticity[1]=(float) image->chromaticity.white_point.y;
(void) TIFFSetField(tiff,TIFFTAG_WHITEPOINT,chromaticity);
}
- if ((image_info->adjoin != MagickFalse) && (GetImageListLength(image) > 1))
+ if ((LocaleCompare(image_info->magick,"PTIF") != 0) &&
+ (image_info->adjoin != MagickFalse) && (GetImageListLength(image) > 1))
{
(void) TIFFSetField(tiff,TIFFTAG_SUBFILETYPE,FILETYPE_PAGE);
if (image->scene != 0)
@@ -3098,7 +3098,8 @@
page=(uint16) scene;
pages=(uint16) GetImageListLength(image);
- if ((image_info->adjoin != MagickFalse) && (pages > 1))
+ if ((LocaleCompare(image_info->magick,"PTIF") != 0) &&
+ (image_info->adjoin != MagickFalse) && (pages > 1))
(void) TIFFSetField(tiff,TIFFTAG_SUBFILETYPE,FILETYPE_PAGE);
(void) TIFFSetField(tiff,TIFFTAG_PAGENUMBER,page,pages);
}
Code: Select all
TIFF Directory at offset 0x300008 (3145736)
Image Width: 1000 Image Length: 1000
Tile Width: 256 Tile Length: 256
[...]
TIFF Directory at offset 0x3c01b8 (3932600)
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 500 Image Length: 500
Tile Width: 256 Tile Length: 256
[...]
TIFF Directory at offset 0x3f0314 (4129556)
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 250 Image Length: 250
Tile Width: 256 Tile Length: 256
[...]