Page 1 of 1

Mogrify modifying even unprocessed files

Posted: 2013-05-26T04:08:36-07:00
by dmitriman
I have a simply batch script which is executed on the contents of a folder. It's meant to resize only images over 1k down to 1k.

mogrify.exe -resize 1024x1024^> c:\xxxxxx\xxxxx\*.tga


After mogrify runs the modified date changes for all the files even those that aren't resized. Is mogrify actually doing something to the files that aren't altered? It was useful for me to keep the modification dates of my files intact.

Re: Mogrify modifying even unprocessed files

Posted: 2013-05-26T11:06:59-07:00
by fmw42
I believe that IM will read the image and write it unprocessed. Thus the time stamp change.

Re: Mogrify modifying even unprocessed files

Posted: 2013-05-26T12:43:18-07:00
by GreenKoopa
You could use identify to determine if each image needs processing. Some examples:

Code: Select all

identify in.tga
identify -format "%wx%h" in.tga
identify -format "%[fx:w>1024||h>1024]" in.tga
Are you using a batch file in Windows? Then you could set up a batch command if. Remember that % needs to be escaped to %% in batch files.

An aside: Instead of using ^ to escape >, you can use quotes, so "1024x1024>". This is more readable, especially since ^ has meaning in IM geometry strings, and leaves you more compatible with other platforms (and readers).