Page 1 of 1

how to prevent image modification if no resizing is done

Posted: 2017-07-26T05:16:01-07:00
by lacsaP
hi,

I've an image :

Code: Select all

$ identify photo.jpg
photo.jpg JPEG 2048x1536 2048x1536+0+0 8-bit sRGB 1.33462MiB 0.000u 0:00.000

$ md5sum photo.jpg
58025fc24f33ae4cb9e7edb94d343f14  photo.jpg
and if I run mogrify on it, my image is altered although it is not resized :

Code: Select all

$ mogrify -resize '2049x1537>' photo.jpg

$ identify photo.jpg
photo.jpg JPEG 2048x1536 2048x1536+0+0 8-bit sRGB 1.34755MiB 0.000u 0:00.000

$ md5sum photo.jpg
b6c86788afea4dbc84ae8a38b58ba728  photo.jpg
how to prevent image modification if no resizing is done ?

regards, lacsaP.

Re: how to prevent image modification if no resizing is done

Posted: 2017-07-26T06:57:54-07:00
by Bonzo
I believe Imagemagick opens an image and saves it; even if nothing is done and so in your case uses jpg compression.

You can check the image size first and only open the image if needs resizing. Get the size from identify, possibly ping the image to get the dimensions or use another piece of software to find the sizes.

Re: how to prevent image modification if no resizing is done

Posted: 2017-07-26T07:54:31-07:00
by lacsaP
I think you are right Bonzo : a preliminary test is necessary in order not to modify the file :-(
IM should be able to follow the final absence of modification for finally not waste time to compress and save the "same" file...