mogrify modifies TIFF images when not requested

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
yecril71pl
Posts: 81
Joined: 2011-02-08T11:06:09-07:00
Authentication code: 8675308
Location: Warsaw, Poland
Contact:

mogrify modifies TIFF images when not requested

Post by yecril71pl »

Code: Select all

convert -size 32x32 canvas:black canvas:gray +append canvas:silver +append canvas:white +append \
  -type Palette c4.tiff &&
mogrify c4.tiff &&
cmp c4.tiff in.tiff
c4.tiff in.tiff differ: char 6, line 1
Mogrify with no operation should create a copy of the original, especially when the original has been created with IM.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: mogrify modifies TIFF images when not requested

Post by magick »

We believe its the date and modify metadata that is changing. Try deleting these properties and your should get the original image. Type
identify -verbose myimage.tiff to see the properties and their values.
User avatar
yecril71pl
Posts: 81
Joined: 2011-02-08T11:06:09-07:00
Authentication code: 8675308
Location: Warsaw, Poland
Contact:

Re: mogrify modifies TIFF images when not requested

Post by yecril71pl »

I inspected the images with tiffinfo; the original image is palette and the mogrified image is grayscale.
I tracked down the problem to MagickReadImage; MagickGetType for this image returns Grayscale.

Workaround:

Code: Select all

MagickSetType (a_wand, PaletteType);
This is important because a 4-colour Palette image grows 4 times when converted to Grayscale.

This problem does not occur when the palette contains colours, as in

Code: Select all

convert -size 32x32 canvas:red canvas:blue +append canvas:green +append canvas:yellow +append \
   -type Palette in.tiff
Non-Workaround:

Code: Select all

MagickSetImageChannelDepth (a_wand, GrayChannels, 02);
This workaround does not work with subtle intensity differences, as lighter shades turn white:

Code: Select all

convert -size 32x32 canvas:black canvas:#e0e0e0 +append canvas:#f0f0f0 +append canvas:white +append \
   -type Palette in.tiff
The converted image ends up as 2-bit Grayscale DirectClass while the original is 2-bit PseudoClass (which is what is needed)
Post Reply