2

I have these files under ./:

a.jpg
b.jpg
256/a.jpg

I'm running this command to convert files to 256px:

mogrify -path ./256/ -resize 256x256 *.jpg

But this command always overrides the existing files in 256, such as 256/a.jpg. Even though the images look the same, git diff still detects changes in the file. How can I avoid overwriting existing files with mogrify?

Versions:

ImageMagick 7.0.10-23 Q16 x86_64 2020-07-05
64bit Mac OS X 10.15.6 19G73

Edit:

My desired result is:

a.jpg
b.jpg
256/a.jpg (Unchanged)
256/b.jpg (Created)

@Sam Forbis' Answer
Using convert -resize 256x256 *.jpg -append ./256/*.jpg would result in:

a.jpg
b.jpg
256/a.jpg (Unchanged)
255/a-0.jpg (Created)
256/a-1.jpg (Created)
1
  • The -write option does what you want. for f in *; do mogrify -quality 0.75 -resize 1024x1024 -write out-$f $f; done
    – jno
    Commented May 2, 2023 at 6:28

1 Answer 1

5

You should use the command convert instead of mogrify. From the man page for mogrify:

Mogrify overwrites the original image file, whereas, convert writes to a different image file.

Looks like the input options are identical for convert. You just need to specify output options and an output file name as specified by the man page for convert:

convert [input-options] input-file [output-options] output-file
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .