crop inside a composite 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
babwar

crop inside a composite image

Post by babwar »

hello,

I have a little problem using imagemagick.

What i want to do is create an image with x images.

It is working perfectely like this :

convert -size 285x285 xc:#1582cb \
image1.jpg -geometry 129x65+13+15 -composite \
image2.jpg -geometry 114x51+159+217 -composite \
final.jpg

But it take exactely image1.jpg and image2.jpg. I want to make a crop from this images in add.

Thanks for your answers..
Last edited by babwar on 2008-01-23T06:47:22-07:00, edited 1 time in total.
babwar

Re: crop inside a composite image

Post by babwar »

I add an image to make it clear :

I want to create a background blue and depose inside 2 images that i can dispose where I want. I can in the same time crop this images.

Exemple in image :

Image

How can i do this in one command line ?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: crop inside a composite image

Post by anthony »

You can crop images when reading them using special image read modifiers. These include, resizing, or cropping the images being read. To do both use the crop method, the resize.
http://imagemagick.org/Usage/files/#read_mods

the alturnative is to use parenthesis to process just the one image before adding it to the canvas.

Code: Select all

   convert canvas.png \
           ....
           \( new_image.jpg  -crop 100x100+20+30 +repage \
                    -resize 50x50   -repage +300+200 \) \
           ....
           -flatten   result.png
Parenthesis... http://imagemagick.org/Usage/basics/#parenthesis
the -flatten is type of multi-image -composition operator.
See Image layering http://imagemagick.org/Usage/layers/
It also can create a background canvas of a specific size, basied on the virtual canvas size of the first image in the image sequence.

Basically you have only just scratched teh surface of multi-image compositions.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply