OVerlapping images

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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

I cheated a bit :shock: I made your graphic a png with a transparent circle where the picture is to go ?

Then I used the code below to create a background, resize the photo and put them all together. There are so many things you can do but I assume you will need to resize the photo. Anyway I am starting to ramble:

Code: Select all

 <?php
exec("/usr/local/bin/convert -size 800x200 xc:none background.png ");
exec("/usr/local/bin/convert pumpkin.jpg -resize 250x250 pumpkin_small.jpg ");
exec("/usr/local/bin/convert background.png -composite pumpkin_small.jpg -geometry +0+30 -composite header.png -composite output.png ");
?>

<img src="output.png">
http://www.rubblewebs.co.uk/imagemagick ... dunphy.php

With Dst_Out you should be able to "punch out" the circle as Anthony puts it but I couldn't get that to work.

http://redux.imagemagick.org/discourse- ... highlight=
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

I have Dst_Out working now; I was using convert instead of composite :roll:
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Bonzo, in it important to get the argument order correct for operations like Dst_Out.

For "composite" the order is source destination
bt it is reversed for easer and more logical use in "convert"

here is the psuedo code.

Code: Select all

    convert   {prepare your destination image -- destination}
                   {prepare your image of the 'hole'  -- source }
                   -geometry {location of hole}  -compose DstOut -composite
                  {further processing or save}
Also not that by tracking what images are in the current image squence (only one after a
-composite) and using parenthesis to handle 'temporary image sequences' you can do
just able ALL your image manipulations all in the same command. This avoids the need for temporary files, and is faster and more accurate as you are not saving images to disk
until you are finished.

I suggest you study the 'Basics' section of IM Examples, especially in regards to the image sequence handling by IM. After that you sould have no more trouble with Alpha compositions in "convert".
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

Thanks for the notes Anthony I will have a look at the ImageMagick basics page again now that I have have had a go at most things. I hate reading things on the monitor so will have to print it out !
I have not done a lot with graphics anyway so things like masks, channels etc. are all new to me.

I had pasted the code above on seperate lines mainly so adunphy could see what each part of the code was doing.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

No problem. though you can see what image is in memory at a point in process by adding "-write" operations. Also you can use -identify to output size information of the images at various points in the processing

PS: writing to "x:" displays the image on screen, and paused the operations until you finish looking.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply