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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

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

Post 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
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

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

Post 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.
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

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

Post by diegomage »

very thankyou for your help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

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

Post by diegomage »

no z.gif is a normal image .
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

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

Post by diegomage »

very thankyou for your help .
Post Reply