Page 1 of 1

combine crop and scale into one command?

Posted: 2013-08-21T14:19:52-07:00
by jedierikb
Currently, I am using two commands, and an intermediate temporary file, to crop and scale images.

Code: Select all

convert src.jpg -crop 50%x50%+10+10 intemediate.jpg
convert intemediate.jpg -distort Resize 100\!x1000\! output.png
Is there a good way to combine these two commands into one command and to prevent the writing of the unnecessary extra file?

Thanks,
Erik

Re: combine crop and scale into one command?

Posted: 2013-08-21T14:32:05-07:00
by snibgo
convert src.jpg -crop 50%x50%+10+10 -distort Resize 100\!x1000\! output.png

Re: combine crop and scale into one command?

Posted: 2013-08-21T14:57:01-07:00
by GreenKoopa
You may want a +repage after the -crop.
http://www.imagemagick.org/Usage/crop/#crop_repage

Lossy formats, such as jpeg, are not ideal for intermediate files.

Re: combine crop and scale into one command?

Posted: 2013-08-21T15:28:16-07:00
by fmw42
convert src.jpg -crop 50%x50%+10+10 -distort Resize 100\!x1000\! output.png

I believe that you only need one \! at the end, thought I suspect that will not hurt otherwise. Also GreenKoopa is right, you need to remove the virtual canvas after a crop if saving to PNG, unless you need to keep it for some reason.

convert src.jpg -crop 50%x50%+10+10 +repage -distort Resize 100x1000\! output.png