Mogrify modifying even unprocessed files

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
dmitriman
Posts: 1
Joined: 2013-05-26T04:02:12-07:00
Authentication code: 6789

Mogrify modifying even unprocessed files

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify modifying even unprocessed files

Post by fmw42 »

I believe that IM will read the image and write it unprocessed. Thus the time stamp change.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Mogrify modifying even unprocessed files

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