Page 1 of 1
How can I maintain quality after 2 convert operations ?
Posted: 2014-02-17T21:21:06-07:00
by tackd
Hi.
I like to downsize large images and save to .tif; (3024x2024) so I can work on them uncompressed later...
$ convert image1.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -colorspace sRBG EndResult.tif
The images meet my requirements... but when I have to save to .jpg format, I'm not sure which method
to 'convert' the downsized 1024 w image to .jpg, to maintain the highest quality.
When I do this in another program (XnViewMP), I use settings;
DCT Method = Float, Subsampling Factor 1x1,1x1,1x1, Smoothing Factor = 0, Quality = 90.
Could someone please offer advise on this, should I convert only once to maintain the highest quality ?
Thank you.
Re: How can I maintain quality after 2 convert operations ?
Posted: 2014-02-17T22:21:23-07:00
by fmw42
General principle is never process to an intermediate jpg format because each write will lose quality due to lossy compression. Either process once with all your commands or save to some lossless intermediate format such as PNG or TIFF. In IM, when saving to jpg, you can use -sampling-factor and -quality. See
http://www.imagemagick.org/script/comma ... ing-factor and
http://www.imagemagick.org/script/comma ... hp#quality. Also see
http://www.imagemagick.org/Usage/formats/#jpg_write
Re: How can I maintain quality after 2 convert operations ?
Posted: 2014-02-18T01:25:32-07:00
by tackd
fmw42,
Aren't I introducing 'some' artifacting via downsizing and saving to tiff via some sharpening ?
$ convert image1.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -colorspace sRBG EndResult.tif
Do you mean If I wish the least amount of artifacing introduced, do not save to tiff, then jpeg...
but resize the large tiff and save to jpg in one step ?
Thank you.
Re: How can I maintain quality after 2 convert operations ?
Posted: 2014-02-18T10:44:01-07:00
by fmw42
Changes by resizing are expected but small depending upon the resize method. You cannot do anything about that. I am saying do not save to JPG and then later read that JPG and do something else and save again to JPG. Use PNG or TIFF which have lossless compression or no compression rather than JPG, which has lossy compression for any intermediate saved file, when you know you are going to do further processing.
Re: How can I maintain quality after 2 convert operations ?
Posted: 2014-02-18T18:17:48-07:00
by tackd
Thanks for your advise fmw42, but I am not asking about saving to jpg.
I am asking about downsizing and saving to .tif, then to jpg from that .tif
vs. downsizing directly to jpg.
Scenario 1 -
$ convert image.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -colorspace sRGB result.jpg
Scenario 2 -
$ convert image.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -colorspace sRGB result.tif
$ convert result.tif result.jpg
Which will maintain the highest quality ?
Thank you.
Re: How can I maintain quality after 2 convert operations ?
Posted: 2014-02-18T18:40:53-07:00
by glennrp
tackd wrote:
Scenario 1 -
$ convert image.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -colorspace sRGB result.jpg
Scenario 2 -
$ convert image.tif -colorspace RGB -filter Lagrange -distort Resize 1024 -colorspace sRGB result.tif
$ convert result.tif result.jpg
Which will maintain the highest quality ?
Thank you.
I'm pretty sure that both scenarios will give you the same result. You can test that assumption
by doing both operations (except ending with result1.jpg and result2.jpg) and then comparing
the two JPG outputs, e.g., with "identify -verbose result1.jpg result2.jpg | grep signature"
Well, I tried it and was surprised to get different signatures for the two outputs. But when
I used PPM instead of TIF as the intermediate file, I got the same result for both
scenarios. So it appears that Scenario 1 was actually better than Scenario 2 with a
TIF intermediate file. The two resulting JPEGs are visually indistinguishable to me,
though.
Re: How can I maintain quality after 2 convert operations ?
Posted: 2014-02-18T18:58:18-07:00
by fmw42
If the tiff file uses JPG compression, then that may be why glennrp results were different and why saving to tiff was not a good idea. You can ensure that the tiff is saved without compression or some other non-lossy compression by using -compress xxx (eg -compress none).