Using -compose Atop with a JPEG

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
Vadr

Using -compose Atop with a JPEG

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using -compose Atop with a JPEG

Post 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/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Using -compose Atop with a JPEG

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Vadr

Re: Using -compose Atop with a JPEG

Post by Vadr »

Thanks very much folks. Exactly the info I needed.
Post Reply