how to prevent image modification if no resizing is done

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
lacsaP
Posts: 2
Joined: 2017-07-26T05:01:30-07:00
Authentication code: 1151

how to prevent image modification if no resizing is done

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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.
lacsaP
Posts: 2
Joined: 2017-07-26T05:01:30-07:00
Authentication code: 1151

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

Post 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...
Post Reply