Page 1 of 1
'convert -monochrome' not working for TIFF?
Posted: 2012-08-17T14:42:10-07:00
by pipitas
What's wrong with the following command? I'm especially confused because the error message mentions JPEG, which isn't involved here:
Code: Select all
convert a.tif -monochrome b.tif
convert: BitsPerSample 1 not allowed for JPEG. `JPEGSetupEncode' @ error/tiff.c/TIFFErrors/508.
The input TIFF is:
Code: Select all
identify a.tif
a.tif TIFF 3500x4040 3500x4040+0+0 8-bit Grayscale DirectClass 646KB 0.000u 0:00.000
Isn't this supposed to work?
This is my ImageMagick:
Code: Select all
convert -version
Version: ImageMagick 6.7.6-9 2012-05-12 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features:
Re: 'convert -monochrome' not working for TIFF?
Posted: 2012-08-17T14:55:41-07:00
by fmw42
Either the tiff has an embedded jpg image or it is jpg compressed. Can you post a link to your image? If not, then what does
identify -verbose yourimage.tif
return
WORKS w. IM v6.7.9-0 [Re.: 'convert -monochrome' not working
Posted: 2012-08-17T18:10:38-07:00
by pipitas
This version works (the very latest I could get):
Code: Select all
convert -version
Version: ImageMagick 6.7.9-0 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Re: 'convert -monochrome' not working for TIFF?
Posted: 2012-08-17T18:19:49-07:00
by pipitas
fmw42 wrote:Either the tiff has an embedded jpg image or it is jpg compressed. Can you post a link to your image? If not, then what does
identify -verbose yourimage.tif
return
A TIFF with an embedded JPEG? I never encountered such a beast!
However...
Code: Select all
identify -verbose a.tif | grep -i compress
Compression: JPEG
The TIFF indeed had been a JPEG in its previous life, and ImageMagick was the obstetrician to help it into its new life as a TIFF.
So indeed, your assumption about the JPEG compression was correct. Is this the standard behaviour of IM (that it JPEG-compresses TIFFs when converting them from a JPEG input, and when no other compression method is given on the commandline)?
Re: 'convert -monochrome' not working for TIFF?
Posted: 2012-08-17T18:31:08-07:00
by fmw42
Where did a.jpg come from? IM? Can you post a link to your tif file? I could be wrong about an imbedded jpg, but the compression jpg may be the issue. I don't know enough about tif
Have you tried
convert a.tif -compress none -monochrome b.tif
Re: 'convert -monochrome' not working for TIFF?
Posted: 2012-08-17T19:13:38-07:00
by pipitas
fmw42 wrote:Where did a.jpg come from? IM? Can you post a link to your tif file? I could be wrong about an imbedded jpg, but the compression jpg may be the issue. I don't know enough about tif
Have you tried
convert a.tif -compress none -monochrome b.tif

Yes -- after I had verified your golden hint about the JPEG compression, I added
'-compress zip' and that worked (with the
'convert' version that perviously failed).
Thanks for all your tireless support. I appreciate it very much!
Re: 'convert -monochrome' not working for TIFF?
Posted: 2012-08-27T18:20:17-07:00
by anthony
pipitas wrote:So indeed, your assumption about the JPEG compression was correct. Is this the standard behaviour of IM (that it JPEG-compresses TIFFs when converting them from a JPEG input, and when no other compression method is given on the commandline)?
When converting to TIFF you should reset the image compression properity, as TIFF can save using JPEG compression.
See IM Examples, TIFF...
http://www.imagemagick.org/Usage/formats/#tiff
JPEG to TIFF conversion...
convert image.jpg image.tif
This will either save the image inside the TIFF file using JPEG compression
(whcih was inherited from the JPG input. Or it will error such as...
Error: "JPEG compression support not configured"
This is caused by the TIFF library not including JPEG compression support.
Either way THIS IS BAD.
You can get around this problem by changing the setting to use a different
compression algorithm:
convert image.jpg -compress zip image.tif
convert image.jpg -compress lzw image.tif
convert image.jpg +compress image.tif