Page 1 of 1

how I could reduce this command for output only one image ?

Posted: 2018-09-11T14:19:52-07:00
by diegomage
I have this code and this output two images ; how I could do for output 1 image

Code: Select all

convert   z1.gif       -morphology Hit-and-Miss '3x3:1,0,1 -,1,- -,-,-'     -negate   -transparent white  hmt_right2.gif   ;convert  z1.gif   hmt_right2x.gif   -composite   z2.gif

reduce this two command to one command

Re: how I could reduce this command for output only one image ?

Posted: 2018-09-11T15:33:27-07:00
by GeeMack
diegomage wrote: 2018-09-11T14:19:52-07:00I have this code and this output two images ; how I could do for output 1 image [...] reduce this two command to one command
One of the simplest ways to combine commands is by isolating the various parts inside parentheses. Here's an example using your commands...

Code: Select all

convert z1.gif \( -clone 0--1 -morphology Hit-and-Miss '3x3:1,0,1 -,1,- -,-,-' -negate -transparent white \) -composite z2.gif
First it reads in the "z1.gif" image. Next, inside the parentheses, it makes a clone of "z1.gif" and runs some operations on it. At that point the original unmodified input image is still there, and it's followed by the other version that was modified inside the parentheses. So the "-composite" at the end is doing exactly what your second command does.

Re: how I could reduce this command for output only one image ?

Posted: 2018-09-11T15:36:57-07:00
by diegomage
very thankyou for your help

Re: how I could reduce this command for output only one image ?

Posted: 2018-09-11T17:25:49-07:00
by fmw42
Why are you doing -clone 0--1? Is your z1.gif a multi-frame animation? If so, then you cannot just composite animations. You need to use -layers composite and null: between the two animations.

Re: how I could reduce this command for output only one image ?

Posted: 2018-09-11T17:51:23-07:00
by diegomage
no z.gif is a normal image .

Re: how I could reduce this command for output only one image ?

Posted: 2018-09-11T19:37:28-07:00
by fmw42
If z1.gif is a single frame, then you should be able to combine these two commands:

Code: Select all

convert z1.gif -morphology Hit-and-Miss '3x3:1,0,1 -,1,- -,-,-' -negate -transparent white  hmt_right2.gif
convert z1.gif hmt_right2x.gif -composite z2.gif

into this one command:

Code: Select all

convert z1.gif \( +clone -morphology Hit-and-Miss '3x3:1,0,1 -,1,- -,-,-' -negate -transparent white \) -composite z2.gif
A clone is just a copy of one of your images. +clone copies that last (previous) image on the command line before it. But to keep any processing from affecting the original z1.gif, you process it inside of parenthesis.

See
https://www.imagemagick.org/script/comm ... .php#clone
https://www.imagemagick.org/Usage/basics/#clone
https://www.imagemagick.org/Usage/basics/#seq_combine
https://www.imagemagick.org/Usage/basics/#complex

Re: how I could reduce this command for output only one image ?

Posted: 2018-09-12T17:21:39-07:00
by diegomage
very thankyou for your help .