Page 1 of 1
mogrify modifies TIFF images when not requested
Posted: 2011-05-02T09:59:16-07:00
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.
Re: mogrify modifies TIFF images when not requested
Posted: 2011-05-02T11:12:10-07:00
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.
Re: mogrify modifies TIFF images when not requested
Posted: 2011-05-02T12:52:27-07:00
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)