overlay image on transparent canvas ImageMagick-5.4.3.11-1

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
hav
Posts: 2
Joined: 2013-05-18T12:55:12-07:00
Authentication code: 6789

overlay image on transparent canvas ImageMagick-5.4.3.11-1

Post by hav »

I'm using an older version of ImageMagick and I'm sure it makes me sound incompetent but how do I overlay one image on another where one is just a transparent png to force specific dimensions for the final image? Many of the documented examples use options which are not, apparently, available in this older version of IM.

I've tried convert -coalesce and composite etc. but I always end up with a background color in what should be transparent space. ... I'm overlaying a jpg on a blank transparent png, if that manes a difference.

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: overlay image on transparent canvas ImageMagick-5.4.3.11

Post by snibgo »

I don't have a version that old, but this might work:

Code: Select all

convert large.png small.jpg -composite out.png
If you output to a format that doesn't support transparency, like jpg, you will lose the transparency.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: overlay image on transparent canvas ImageMagick-5.4.3.11

Post by fmw42 »

that old IM version would probably need the composite command and not convert. you would be well of if you can upgrade (that version is about 1400 versions old)

composite -compose over small large_transparent result

see
http://www.imagemagick.org/Usage/basics/#cmdline
http://www.imagemagick.org/Usage/layers/#composite
http://www.imagemagick.org/Usage/compose/#compose
hav
Posts: 2
Joined: 2013-05-18T12:55:12-07:00
Authentication code: 6789

Re: overlay image on transparent canvas ImageMagick-5.4.3.11

Post by hav »

Thanks guys - yes - composite -compose ... worked well - ... actually, it turns out, so did convert -coalesce large-transparent small-overlay -flatten output - I had just viewed the result with the browser directly but, in a rendered page, it was fine - sorry

yes - I'm not completely sure why the admin chose the old version to install?? something about an old server... I'll look into it more.

Thanks again!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: overlay image on transparent canvas ImageMagick-5.4.3.11

Post by anthony »

If the image you are overlaying on is transparent why not do this..

Code: Select all

convert layer_image.png  -background none -extent WIDTHxHEIGHT+X+Y  enalrged_canvas_image.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply