[Solved] Overlaying image onto animation aligned improperly

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
meridionaljet
Posts: 2
Joined: 2011-05-15T22:32:36-07:00
Authentication code: 8675308

[Solved] Overlaying image onto animation aligned improperly

Post by meridionaljet »

Hello,

I'm on Ubuntu 11.04, and am trying to overlay a static blue coastline image onto a geostationary GIF animation with 12 frames using imagemagick.

The code I used to create the composite animation is as follows:

Code: Select all

convert \( animation.gif -coalesce \) null: \( outline.tif -coalesce \) -layers Composite composite_animation.gif
The resulting animation is below:

Image

It's a bit hard to see, but the blue outline should be aligned much farther to the left on the image, but the vast majority of it is cut-off to the right because it is shifted so far. It should be centered. Both the outline and the background are actually cropped regions out of respectively larger images that are identical in size and are designed to be overlaid. If I choose a cropped region farther to the right on the background animation, the cropped blue outline of the same region won't even show up at all after the overlaying, as if it is shifted completely off the screen for some reason.

I have had success overlaying outlines before with the above command, but here it is not working. I tried appending "-gravity center" to the command with no success. If anyone can help, it would be appreciated.
Last edited by meridionaljet on 2011-05-16T17:33:15-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Overlaying image onto GIF animation is aligned improperl

Post by anthony »

Cropping does NOT remove the virtual canvas offsets. That can be particularly important in animations with frame optimization. See IM examples Animation Modifications, Cropping, and next section Cropping Canvas too.
http://www.imagemagick.org/Usage/anim_mods/#crop

However as your images are probably full-frame animations (equivalent to coalesced, in which case you don't need that option and definitely not for a static single frame image). As such you can just use +repage after your crop to remove the crop offset. See IM Examples, Cutting and Bordering, Crop, Remove Offset
http://www.imagemagick.org/Usage/crop/#crop_repage
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
meridionaljet
Posts: 2
Joined: 2011-05-15T22:32:36-07:00
Authentication code: 8675308

Re: Overlaying image onto GIF animation is aligned improperl

Post by meridionaljet »

anthony wrote:Cropping does NOT remove the virtual canvas offsets. That can be particularly important in animations with frame optimization. See IM examples Animation Modifications, Cropping, and next section Cropping Canvas too.
http://www.imagemagick.org/Usage/anim_mods/#crop

However as your images are probably full-frame animations (equivalent to coalesced, in which case you don't need that option and definitely not for a static single frame image). As such you can just use +repage after your crop to remove the crop offset. See IM Examples, Cutting and Bordering, Crop, Remove Offset
http://www.imagemagick.org/Usage/crop/#crop_repage
This was exactly what I needed. You're a savior. Thanks a lot.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: [Solved] Overlaying image onto animation aligned imprope

Post by anthony »

Can you post a properly working version of the previous example? Just for reference.

I can see why you want to mark the coastline, it seems hard to make out.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply