Help me to understand below CLI

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
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Help me to understand below CLI

Post by rpatelob »

Code: Select all

convert one.jpg two.jpg -compose over \
-alpha off -compose copy_opacity -composite  three.jpg  \
+swap +repage -gravity center -compose over -composite output.jpg
I'm trying to convert above CLI into C. But I don't understand the meaning of it. Can anyone please explain about it?
This is what I understood from it.
  • First perform alpha off and compose over on one.jpg and two.jpg and then merge them using copy_opacity composite.
  • Swap three.jpg with newimage then apply gravity on them and finally merge them using over composite and generate the output.jpg
So I devided CLI into two steps like this.

Code: Select all

#First CLI
convert one.jpg two.jpg -compose over -alpha off -compose copy_opacity -composite output_one.jpg

# Second CLI
convert output_one.jpg three.jpg  +swap +repage -gravity center -compose over -composite output.jpg
The expected output using this does not match with the output generated from single CLI so I think I completely misunderstood it.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Help me to understand below CLI

Post by snibgo »

The first "-compose over" setting is never used, so you could remove it.

"-compose copy_opacity -composite" will create transparency in the image. Saving this as JPG will remove transparency.
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: Help me to understand below CLI

Post by rpatelob »

Thank you @snibgo, I understood. I was saving image as jpeg using first CLI so it would remove transparency.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Help me to understand below CLI

Post by glennrp »

rpatelob wrote: 2017-05-28T22:38:42-07:00 I was saving image as jpeg using first CLI so it would remove transparency.
That's not a great way of removing transparency, due to the lossy conversion to JPEG. There are ways of removing transparency via "-alpha " options, but if you like the simplicity of converting to an opaque image format, use PPM for that.
Post Reply