Page 1 of 1

"Only Shrink Larger Images" also modifies smaller images

Posted: 2008-04-09T03:46:01-07:00
by inigomena
Hi, I'd like to use the option to "Only Shrink Larger Images", but I find that it also modifies the smaller images, I guess it recompresses them without resizeing it. I think it should not alter the files if it is not necessary, is there a way to preserve the smaller images so they are not altered? If not, it would be a good improvement.

Re: "Only Shrink Larger Images" also modifies smaller images

Posted: 2008-04-09T04:39:09-07:00
by Bonzo
http://www.imagemagick.org/script/comma ... php#resize

As you have not posted you code I am guessing you need to read the link above.

Re: "Only Shrink Larger Images" also modifies smaller images

Posted: 2008-04-09T06:16:23-07:00
by inigomena
I am using command line 'convert':
convert one.jpg -resize "640x480>" other.jpg

The source file is 624x396 and 68KB. The new file is 624x396 (OK) but it is 62KB. I don't want it to modify files unless it is necessary to resize them (I want to use it in a batch process for a lot of files, some of them will need to be resized but I don't want to modify the others).

Re: "Only Shrink Larger Images" also modifies smaller images

Posted: 2008-04-09T07:14:54-07:00
by Bonzo
I would think that is due to jpg compression; I do some tests with different -quality settings to see what happens.

Re: "Only Shrink Larger Images" also modifies smaller images

Posted: 2008-04-09T07:26:16-07:00
by inigomena
Yes, I think it loads the picture, checks whether it needs to resize it and then saves it again, recompressing in jpg format; if it has not needed to make changes, it would be better to leave the picture as it is, without saving it again.

Re: "Only Shrink Larger Images" also modifies smaller images

Posted: 2008-04-09T07:30:04-07:00
by Bonzo
Yes I have just done a test:

original image = 13560
-quality 90 = 6784
-quality 60 = 3955
-quality 30 = 2842

Code: Select all

<?php
exec ("convert after.jpg -resize \"640x480>\" -quality 30 30.jpg");

exec ("convert after.jpg -resize \"640x480>\" -quality 60 60.jpg");

exec ("convert after.jpg -resize \"640x480>\" -quality 90 90.jpg");

?>

Re: "Only Shrink Larger Images" also modifies smaller images

Posted: 2008-04-09T11:07:23-07:00
by fmw42
IM uses a default of 80 for jpg quality and will likely do what you are seeing, rewrite the output. I suspect you will need to write a script to test the dimensions of the image and then process it if it is large enough and skip the resize command line if small enough.

You can try posting to the Bugs forum and see what they say.