Page 1 of 1

Can these processes be done at once

Posted: 2015-09-14T10:41:49-07:00
by kereilly
I'm writing a script where i'm processing a lot of images. I create 4 files for each batch of images and I only need the last. i'm wondering if i can condense what i'm doing. Here is the first command:

Code: Select all

convert f1.png f2.png f3.png f4.png f5.png -evaluate-sequence Min -threshold 60% -negate output.png
this is the first step. But from here i only need two pieces of the image

Code: Select all

convert output.png -crop 80x35+90+40 left.png
convert output.png -crop 220x35+420+40 right.png
Now i'd like them to be one image again so i do

Code: Select all

convert -append left.png right.png final.png
Now i've created output.png, left.png, right.png and final.png. I can just erase all those with my script but can i do the cropping and appending within my first line? Seems it would save me time when doing lots of these. Thanks for the help.

Re: Can these processes be done at once

Posted: 2015-09-14T11:43:58-07:00
by snibgo
Untested, but I think this will work. I've split it into lines for ease of reading. Your script language will need a special character at line-ends.

Code: Select all

convert
  f1.png f2.png f3.png f4.png f5.png
  -evaluate-sequence Min -threshold 60% -negate
  ( -clone 0 -crop 80x35+90+40 )
  ( -clone 0 -crop 220x35+420+40 )
  delete 0
  -append
  final.png

Re: Can these processes be done at once

Posted: 2015-09-14T12:34:20-07:00
by kereilly
Thanks for the post. Probably should have stated i'm on a Mac and i'm running Version: ImageMagick 6.9.0-0 Q16 x86_64 2015-07-27
When i tried your code i get a bash error '(' unexpected syntax. When i take the Parentheses out i get this:

convert: geometry does not contain image `f1.png' @ warning/transform.c/CropImage/666.
convert: unable to open image `delete': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
convert: unable to open image `0': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.

Also is the second clone still supposed to be 0 or should it be 1? and i should delete before i append? Sorry real novice at Imagemagick. Not sure what i'm doing here. Seems if i delete the clones their is nothing to append?

Re: Can these processes be done at once

Posted: 2015-09-14T13:29:36-07:00
by snibgo
Bash requires that parentheses are escaped: \( and \) . (That's a feature of bash, not ImageMagick.) Put an escape character \ at the end of each line.

I wrote "delete" when I should have written "-delete". (With a minus.) Sorry.

"-delete 0" deletes image zero from the list, so the two clones will remain, to be appended.

Re: Can these processes be done at once

Posted: 2015-09-14T14:32:05-07:00
by kereilly
That did it! Thank you very much sir