Page 1 of 1

Compose into new image

Posted: 2011-05-19T05:28:11-07:00
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!

Re: Compose into new image

Posted: 2011-05-19T05:53:22-07:00
by glennrp
"-compose" takes an operator, e.g., "-compose over"

Re: Compose into new image

Posted: 2011-05-19T07:25:16-07:00
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

Re: Compose into new image

Posted: 2011-05-19T17:13:01-07:00
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