possible bug ptif tile -define IM 6.7.4.7 Q16

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug ptif tile -define IM 6.7.4.7 Q16

Post by fmw42 »

IM 6.7.4.7 Q16 Mac OSX Snow Leopard

In reference to: viewtopic.php?f=1&t=20193&p=80040#p80026

I am no expert on PTIF, but it looks to me like the -define for the tile size is not working. I would expect the last level to be the tile size. Correct me if I am wrong.

convert -size 1024x1024 gradient: grad1024.png
convert grad1024.png -define tiff:tile-geometry=128x128 ptif:grad1024.tif

identify grad1024.tif
grad1024.tif[0] TIFF 1024x1024 1024x1024+0+0 16-bit Grayscale DirectClass 42.7KB 0.000u 0:00.000
grad1024.tif[1] TIFF 512x512 512x512+0+0 16-bit Grayscale DirectClass 42.7KB 0.000u 0:00.000
grad1024.tif[2] TIFF 256x256 256x256+0+0 16-bit Grayscale DirectClass 42.7KB 0.000u 0:00.000
grad1024.tif[3] TIFF 128x128 128x128+0+0 16-bit Grayscale DirectClass 42.7KB 0.000u 0:00.000
grad1024.tif[4] TIFF 64x64 64x64+0+0 16-bit Grayscale DirectClass 42.7KB 0.000u 0:00.000

I also get the same results from using -define tiff:tile-geometry=256x256

So it looks to me like it is creating tiles of 64x64, which may be the default and thus the -define is not working or not documented correctly.
Last edited by fmw42 on 2013-08-01T17:04:59-07:00, edited 2 times in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible but ptif tile -define IM 6.7.4.7 Q16

Post by magick »

The tile-geometry define refers to how pixels are stored inside any TIFF image. For example:
  • convert logo: -define tiff:tile-geometry=128x128 logo.tif
    -> tiffinfo logo.tif
    TIFF Directory at offset 0x7404 (29700)
    Image Width: 640 Image Length: 480
    Tile Width: 128 Tile Length: 128
The pyramid-encoded TIFF image halfs the image size until it is less that 64x64. Currently you cannot define this value.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible but ptif tile -define IM 6.7.4.7 Q16

Post by fmw42 »

The pyramid-encoded TIFF image halfs the image size until it is less that 64x64. Currently you cannot define this value.
So then for tile sizes larger than 64x64, any levels below the tile size will be padded to the tile size specified, such as in this case, the last level will be 128x128, but only have image data for 64x64 and padded out to 128x128?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible but ptif tile -define IM 6.7.4.7 Q16

Post by magick »

Storage is handled by the TIFF library, not ImageMagick. Specifically we simply take the value from the define and set the TIFFTAG_TILEWIDTH and TIFFTAG_TILELENGTH fields. For exactly how storage is handled when a tile geometry is specified refer to the libtiff documentation or the TIFF format specification.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible but ptif tile -define IM 6.7.4.7 Q16

Post by fmw42 »

thanks for the information and the reference to tiffinfo as I could not find any of that data listed in the IM verbose info:

someday it would be nice if the IM verbose info could identify the tiff as ptif format and the tile size info.

do you know of any (Mac or Unix) tools that will view PTIFs? Even Photoshop does not seem to be able to handle it, though I am no expert on its use.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible but ptif tile -define IM 6.7.4.7 Q16

Post by fmw42 »

Turns out that GIMP will display PTIFs (all levels or select a level) as images or layers, BUT only if the image is depth 8. In IM, display will only show the first level (largest) but also only if -depth 8

So use:

convert -size 1024x1024 gradient: grad1024.png
convert grad1024.png -define tiff:tile-geometry=128x128 -depth 8 ptif:grad1024.tif
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible but ptif tile -define IM 6.7.4.7 Q16

Post by magick »

We can reproduce the problem you reported. We'll get a patch into the next point release of ImageMagick. Thanks.
Post Reply