Page 1 of 1

Using -compose Atop with a JPEG

Posted: 2009-09-09T13:31:08-07:00
by Vadr
Hi All,

Please forgive a noob. I've scanned the docs and this board, but I need a clear answer to this question fairly quickly. I'm a new developer at this company and am not familiar with IM.

Currently, we use IM to allow customers to upload a .gif file, and then we use -compose atop to overly another, smaller gif on top of the original.

The customer has requested the capability to upload .jpg files, and need the same overlay capability.

Can I use -compose Atop to overlay a .gif onto a .jpg? A .jpg onto a .jpg?

...and I'm pretty sure I need an add-on (delegate?) to handle .jpgs at all?

Many Thanks

Re: Using -compose Atop with a JPEG

Posted: 2009-09-09T16:39:29-07:00
by fmw42
jpeg does not support transparency. so if you are using transparency you can only overlay a transparent gif onto a jpg. you will not be able to use transparency in a jpg to overlay a transparent jpeg over another jpeg or any other image.

However, you can upload the jpeg, then convert it to gif or png for transparency and then overlay that onto any other image.

Once done you can flatten the image so that the transparency is removed leaving the image composited with the appropriate background color

If you are not using transparency, then you can compose two images, the smaller one atop the other and position it where you want.

see the various ways to overlay one image with another at
http://www.imagemagick.org/Usage/layers/
http://www.imagemagick.org/Usage/compose/

I defer to Anthony or Magick to correct me on this if wrong.

If you have installed IM from source, then you will need to install any appropriate image format delegate library. To see what IM knows you have installed, type

convert -list configure

And look for the line starting with DELEGATES

Some of the common delegates can be downloaded from http://www.imagemagick.org/download/delegates/

Re: Using -compose Atop with a JPEG

Posted: 2009-09-09T22:06:38-07:00
by anthony
As the base (background) image is a JPEG, you can simply use the default 'Over' for the composition and get the same results. This should work fine for GIF's with transparency as well.

The only time you may get problems with this is if the background image contained transparency. In that case ATop is different to Over, and you may need to ensure the base image contains a alpha channel. You also can not then save into JPEG whcih can not save alpha transparency. PNG would then probably be better.

Re: Using -compose Atop with a JPEG

Posted: 2009-09-10T12:15:16-07:00
by Vadr
Thanks very much folks. Exactly the info I needed.