Compose into new image

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
eddieconnecti
Posts: 4
Joined: 2011-05-17T08:09:34-07:00
Authentication code: 8675308

Compose into new image

Post by eddieconnecti »

Hi there! I would like to copy an image into a new, blank image, and overwrite the overlay by the way and can´t get it to work...

Step by step what the command should do:
- create a new image width size 200x200, xc:none
- compose a source image "c:\image.png" onto image at position 10x10
- save as "c:\image.png"

The trick should be not to create a new image in the filesystem, but to create a new blank one on the fly, copy the source image at given position, and save as the source file to overwrite it.
I would like to use this method to add padding to existing images.

This code does not work:

Code: Select all

C:\Program Files\ImageMagick\convert.exe -size 200x200 xc:none\\ C:\Program Files\ImageMagick\composite.exe -geometry +x+y -compose c:\image.png c:\image.png

Thanks for any help!
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Compose into new image

Post by glennrp »

"-compose" takes an operator, e.g., "-compose over"
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Compose into new image

Post by Bonzo »

Try something like:

Code: Select all

C:\Program Files\ImageMagick\convert.exe -size 200x200 xc:none c:\image.png -geometry +x+y -composite c:\image.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Compose into new image

Post by anthony »

glennrp wrote:"-compose" takes an operator, e.g., "-compose over"
That is also the default "setting", so is generally not needed. The operator that is needed is -composite. and '+x+y' should be +10+10 for the offset to actually work!

however in this case you can also use -flatten that can generate that canvas for you...

Code: Select all

convert.exe c:\image.png -background none -repage 200x200+10+10 -flatten  c:\image.png
or even use extent though it seems strange that you need to specify a negative position rather than an image position as such I probably would not rely on it remaining this way, as it seems nonsensical!

Code: Select all

convert.exe c:\image.png -background none -extent 200x200-10-10  c:\image.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply