How to set gravity or geometry?

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
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

How to set gravity or geometry?

Post by agriz »

Code: Select all

convert -size 550x700 xc:none ( image.png -rotate -2 ) ( -clone 1  )  -layers merge output.png
how do i move the -clone 1 image to right side of the document?
instead of -layers merge how can i use composite and position the images using geometry or gravity? I have to include few more images and i have to rotate them.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to set gravity or geometry?

Post by fmw42 »

Work with images in pairs to use -gravity, -geometry and -composite. See http://www.imagemagick.org/Usage/layers/#convert
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: How to set gravity or geometry?

Post by agriz »

Sir,what if I have to delete some of the images during the process?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to set gravity or geometry?

Post by fmw42 »

agriz wrote:Sir,what if I have to delete some of the images during the process?
I do not understand. Once you composite two images, they are automatically deleted leaving only the composite results. So you just composite the first two, then add a new image and composite that with the previous composite result and so on.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: How to set gravity or geometry?

Post by agriz »

I dont have any coding to share. I am just collecting ideas.

Code: Select all

assusming image size is 400x400
convert -size 400x400 xc:none ( img.jpg -crop 100x100 ) ( -clone 1 ) ( -clone 2 ) ... -delete 1 output.jpg
I can position the clones using temp images in different convert command. i need to write multiple convert commands for that.

In the above example how can i position cropped images in different position. Here i can't write composite. Because i need to delete the img.jpg in the end.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to set gravity or geometry?

Post by fmw42 »

I do not understand what you are trying to do.

Your code does not show any composite. So you will get one output image for each input image.

If you want to change the order, then use -swap as I mentioned earlier. See http://www.imagemagick.org/Usage/basics/#swap
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: How to set gravity or geometry?

Post by agriz »

Sir in the above code, how can i use composite before deleting the ( img.jpg -crop 100x100 )?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to set gravity or geometry?

Post by fmw42 »

agriz wrote:Sir in the above code, how can i use composite before deleting the ( img.jpg -crop 100x100 )?

First -delete1 will not remove ( img.jpg -crop 100x100 ), it will remove ( -clone 1 ). Image indices start at 0 not 1.

Second I am not sure what you are trying to composite. You cannot use -composite for more than two images at a time as I mentioned earlier. But you can flatten them all.

Why do you need the clones? ( img.jpg -crop 100x100 ) will make many smaller 100x100 images and will have automatically remove img.jpg. By cloning each one, you are making twice as many 100x100 subsections.

Have you tried

Code: Select all

convert -size 400x400 xc:none ( img.jpg -crop 100x100 ) -background none -flatten result.png
Does that do what you want?

Is img.jpg larger than 400x400? If so, you will be trying to put all the 100x100 pieces back over the 400x400 image in the places they were cropped and this will not fit the 400x400 transparent image.

Perhaps you should explain in more detail and show img.jpg so we can understand what it is you are trying to do.
Post Reply