Page 1 of 1
Converting from jpg to tif, then tif to tif ruins colors.
Posted: 2010-09-17T13:34:00-07:00
by tryl
Hi
I need to run a lot of programs (ImageMagick and others) on the same jpg image, so I want to convert it to a tif as working format.
Running
produces a perfect result. But if I then run
Code: Select all
convert picture.tif newpicture.tif
which should produce the same result, newpicture.tif is converted to something that looks like 16 colors.
When running the tif to tif conversion (which is run completely separate from the jpg to tif conversion) i get the error message:
Code: Select all
convert: Caution: quantization tables are too coarse for baseline JPEG. `JPEGLib'.
Re: Converting from jpg to tif, then tif to tif ruins colors
Posted: 2010-09-17T13:52:20-07:00
by lwhistler
Why not just copy the file?
cp picture.tif newpicture.tif
-------
Re: Converting from jpg to tif, then tif to tif ruins colors
Posted: 2010-09-17T14:05:29-07:00
by tryl
I want to run some operations on it (e.g. -colorspace gray), but this reduces the example to the simplest form.
Re: Converting from jpg to tif, then tif to tif ruins colors
Posted: 2010-09-17T14:09:15-07:00
by lwhistler
I'm not sure if this would work:
convert picture.jpg -colorspace gray picture.tif
Re: Converting from jpg to tif, then tif to tif ruins colors
Posted: 2010-09-17T14:31:04-07:00
by lwhistler
This is interesting:
http://www.imagemagick.org/Usage/formats/#tiff
and
http://www.imagemagick.org/Usage/formats/#jpg_lossless
Looks like lossless jpg is the way to go with ImageMagick, instead of tiff's.
----
Re: Converting from jpg to tif, then tif to tif ruins colors
Posted: 2010-09-17T17:07:30-07:00
by Drarakel
tryl wrote:When running the tif to tif conversion (which is run completely separate from the jpg to tif conversion) i get the error message:
Code: Select all
convert: Caution: quantization tables are too coarse for baseline JPEG. `JPEGLib'.
Are you sure that this warning comes from the second conversion (TIFF to TIFF), and not from the first conversion? With a current ImageMagick version, such a message can occur with certain JPG->TIFF conversions. But maybe you have an older ImageMagick version (or an older libtiff or jpeg library)...
Anyway: This is usually an effect of an input JPG having a very low quality. (With a current version, this happens if IM identifies a quality value of 23 or below.) The resulting TIFF should be still ok, but it's less compatible - some viewers might have problems with that.
What viewer did you use for these TIFF files? And: What ImageMagick version do you have (on which operating system)? If the version is old, then try to upgrade first.
tryl wrote:Running
produces a perfect result.
Even if you had no error: I wouldn't recommend the above command line - at least if you use the TIFF files as intermediate format. ImageMagick usually tries to use the compression method and the 'quality value' from the input file for a conversion (if you don't specify a certain compression). JPG compression can also be used in TIFF files - thus a standard JPG->TIFF conversion will result in a lossy recompression (which degrades the quality). I recommend using a compression that's not lossy - e.g. the ZIP compression (for a low filesize):
Code: Select all
convert picture.jpg -compress zip -quality 90 picture.tif
If you don't care about the filesize of your intermediate files, but about speed, then just use no compression:
Code: Select all
convert picture.jpg -compress none picture.tif
Re: Converting from jpg to tif, then tif to tif ruins colors
Posted: 2010-09-18T03:30:45-07:00
by tryl
Drarakel wrote:I wouldn't recommend the above command line - at least if you use the TIFF files as intermediate format. ImageMagick usually tries to use the compression method and the 'quality value' from the input file for a conversion (if you don't specify a certain compression). JPG compression can also be used in TIFF files - thus a standard JPG->TIFF conversion will result in a lossy recompression (which degrades the quality). I recommend using a compression that's not lossy - e.g. the ZIP compression (for a low filesize):
Code: Select all
convert picture.jpg -compress zip -quality 90 picture.tif
If you don't care about the filesize of your intermediate files, but about speed, then just use no compression:
Code: Select all
convert picture.jpg -compress none picture.tif
Thank you Drarakel for this insight that I was completely unaware of. I don't care about file size and -compress none solves my problem perfectly.
Thank you very much!
Re: Converting from jpg to tif, then tif to tif ruins colors
Posted: 2010-09-19T16:10:50-07:00
by anthony
From IM Examples, Formats, 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 JPE 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
WARNING: -compress Group4 with a TIFF works, but ONLY if you remove all
transparent and semi-transparent pixels from the image. Typically you can
make sure this is done the same way as JPEG images above, using
-background {color} -flatten
just before the final save.