Overlapping Photos doesn't work

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
TanEsal

Overlapping Photos doesn't work

Post by TanEsal »

Hi

Could you advice what's wrong. I want to overlap photos and used example from http://www.imagemagick.org/Usage/photos/#overlap

Code: Select all

//Mask
exec("/usr/local/bin/convert -size 90x80 xc:white xc:black -size 90x40 gradient: +swap -append -rotate 90 overlap_mask.png");

//Overlaped  
exec("/usr/local/bin/convert holocaust_tn.gif -extent 200x90 spiral_stairs_tn.gif overlap_mask.png -gravity East -composite overlap_photos.jpg");
Here is a result which don't have transparensy but I don't know why:
Image

Created mask:
Image

It is a GoDaddy hosting, may be it will add something useful.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Overlapping Photos doesn't work

Post by fmw42 »

Godaddy hosting is at 6.2.7 for IM. It is extremely old (over 350 versions old). That is probably the problem. Unfortunately, I have asked several times, but could not get Godaddy to upgrade its version of IM. So possibly one of the options you are using in your commands was not implemented or buggy at that old version. Most likely -extent. See http://www.imagemagick.org/Usage/crop/#extent Or possibly something with -composite.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Overlapping Photos doesn't work

Post by anthony »

The -extent seemed to work fine.

What looks like happened is that the overlay image was modified by the mask rather than the mask being used to mix images.

Before IM v6.3.4-11 composite masking erroniously used the mask as a 'transparency' mask for the source image rather than a selection or mixing mask between the results and the original image.
See Composite Mask Bug
http://www.imagemagick.org/Usage/bugs/composite_mask/

As the images do not contain transparency the solution is simple. Extend the background image eastward (as it is now doing), but also extend the overlay image westward. Then ensure ALL images have an alpha channel (-matte) before doing the masked overlay.

Alternately, mask the overlay image with the appropriate transparency, then overlay!
That will however mean the mask has to be adjusted to match the overlay image.

I do not recommend simply adding an alpha channel and resizing the mask so as to match the overlay image, though for that version of IM it will work. The problem is that will break when IM is finally updated.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply