Usage Example - Not working as expected

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
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Usage Example - Not working as expected

Post by agriz »

Code: Select all

convert /( tile_aqua.jpg -resize 200% /) /( tile_water.jpg -gravity center /) /( moon_mask.gif -gravity center /) -composite output.png
I expected the moon to be in the center.
But it is in the top right corner and the moon is not properly visible too.

Code: Select all

convert /( tile_aqua.jpg -resize 200% /) /( tile_water.jpg  /) /( moon_mask.gif /) -composite output.png
However, this is working good.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Usage Example - Not working as expected

Post by fmw42 »

First your slashes / need to be \. Next, the -gravity and -composite needs to be applied separately, unless the images are all the same size.

Try this

Code: Select all

convert \
\( tile_aqua.jpg -resize 200% \) \
\( tile_water.jpg moon_mask.gif -gravity center -alpha off -compose copy_opacity -composite \) \
-gravity center -compose over -composite output.png
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Usage Example - Not working as expected

Post by agriz »

Thank you
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Usage Example - Not working as expected

Post by agriz »

Code: Select all

convert image.png \( -clone 0 rose.png -compose Over -composite  \) \
\(  shape.png \) -delete 0 -alpha off -compose copy_opacity -composite \
image.png +swap -gravity center -compose Over -composite output.png
i used the image.png two times. I am not able to use the clone because i have to delete it while applying shape.png
Is it okay to call the same image multiple times? or should i clone it? If i have to clone, how can i do this coding?
Last edited by agriz on 2016-06-25T00:51:32-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Usage Example - Not working as expected

Post by snibgo »

Why not write it to an "mpr:"?
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Usage Example - Not working as expected

Post by agriz »

Thank you sir. I have to read about it. I will try it and tell you.
Thanks for the advice
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Usage Example - Not working as expected

Post by agriz »

It's working and what is the difference between clone and mpr which one should i use?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Usage Example - Not working as expected

Post by snibgo »

Clone and mpr are two different ways of doing similar things, of using images in memory.

A clone can only use an image that is in the immediately outer list. You can't write a clone; you can only read a clone.

By contrast, an mpr has to be explicitly written before it can be used. Once it is written, it can be used anywhere after that in the same "convert" statement.
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Usage Example - Not working as expected

Post by agriz »

Are both of them using same memory?
You said we need to write an MPR. So will it use much memory than clone?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Usage Example - Not working as expected

Post by snibgo »

Using +clone or -clone to read a clone just creates pointers to the images.

Using +write mpr:ABC or -write mpr:ABC to write images just creates pointers.

Using mpr:ABC to read mpr just creates pointers.
snibgo's IM pages: im.snibgo.com
Post Reply