mogrify: don’t save if no change

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
User avatar
jdaw1
Posts: 1
Joined: 2017-06-14T10:05:02-07:00
Authentication code: 1151
Location: London
Contact:

mogrify: don’t save if no change

Post by jdaw1 »

Hello. I’m using mogrify for the very simple task of “-trim +repage” (which should be an option in Excel VBA’s Chart.Export, but isn’t).

Please, is there a simple means of instructing mogrify not to save the file if there hasn’t been a change. So that if I were to re-“mogrify -trim +repage *.png”, the file modification dates would not change?

Thank you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: mogrify: don’t save if no change

Post by fmw42 »

ImageMagick has no feature to my knowledge that knows when there is a no-op and not to process the image. I will defer to the IM developers to correct me, if I am wrong. I think you need to loop over each image and check the trim coordinates using the string format "%@". Then compare the input width to result from that result and then decide to process or not. See http://www.imagemagick.org/script/escape.php
Post Reply