Page 1 of 1

mogrify -trim and -flatten in 1 command not working

Posted: 2016-05-13T06:45:18-07:00
by seansan
We are processing 500 images tiff and jpg using this command

Code: Select all

mogrify -path "PATH_TO\DONE" -trim -flatten -define jpeg:extent=500kb -format jpg -resize "1200x1200>" *.*
It should open all images, trim the image, flatten the image, resize to 1200px and then save in optimal jpg quality with a filesize lower than 500kb.

I thought I hadd it all working. Then I had to add -flatten to process the tiff files (otherwise 3 outputted files) and as a result the -trim stopped working on all images. Now the images are all OK, just not trimmed.

question: how can I force the trim command to work in this context?

Help appreciated

Re: mogrify -trim and -flatten in 1 command not working

Posted: 2016-05-13T07:07:05-07:00
by seansan
This seems to work but we don't know why repage is necessary here

Code: Select all

mogrify -path "PATH\DONE" -layers merge +repage -trim -resize "1200x1200>" -define jpeg:extent=500kb -format jpg *.*

Re: mogrify -trim and -flatten in 1 command not working

Posted: 2016-05-13T07:26:11-07:00
by snibgo
"-trim" creates canvas dimensions and offsets for each image, that gives the location of the trimmed area on the original image. "-layers merge" uses canvas dimensions and offsets for the alignment of layers. "+repage" removes canvas dimensions and offsets, so they will be aligned by top-left corners.

See documentation http://www.imagemagick.org/script/comma ... php#repage etc.