Page 1 of 1

mogrify: don’t save if no change

Posted: 2017-06-15T02:23:04-07:00
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.

Re: mogrify: don’t save if no change

Posted: 2017-06-15T09:23:47-07:00
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