Page 1 of 1

Help me to understand below CLI

Posted: 2017-05-26T02:19:10-07:00
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.

Re: Help me to understand below CLI

Posted: 2017-05-26T07:50:11-07:00
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.

Re: Help me to understand below CLI

Posted: 2017-05-28T22:38:42-07:00
by rpatelob
Thank you @snibgo, I understood. I was saving image as jpeg using first CLI so it would remove transparency.

Re: Help me to understand below CLI

Posted: 2017-05-29T08:10:07-07:00
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.