Align shapes with bottom of 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
rssjm
Posts: 2
Joined: 2012-09-30T08:15:49-07:00
Authentication code: 67789

Align shapes with bottom of image

Post by rssjm »

I would like to be able to align all shapes within an image to the bottom of it. The images below show what I am trying to achieve with before/after. I was working with the -gravity option but I just wasn't able to get them to drop vertically. Any tips or general idea of how I would go about this is much appreciated.

Image

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Align shapes with bottom of image

Post by fmw42 »

see
http://www.imagemagick.org/Usage/layers/#convert

Use -gravity and -geometry. You can use -gravity south to place them at the bottom center and then use -geometry to offset them as desired.

This assumes you have each shape as a separate image. If not then use my (unix bash) script, separate, to separate them into individual shapes and then follow up as above.
rssjm
Posts: 2
Joined: 2012-09-30T08:15:49-07:00
Authentication code: 67789

Re: Align shapes with bottom of image

Post by rssjm »

Thanks for the tips Fred, I actually used another thread to start my search that you gave great information in but wasn't able to cross this final bridge. Could you please specify which script you are talking about. Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Align shapes with bottom of image

Post by fmw42 »

My "separate" script is listed at the link below. That will allow you to automatically crop out each of the shapes. You may have to negate the image so that the shapes are white on black. Then once separate, you will then need to negate them back. You probably will then need to use -trim +repage to get them cropped to the minimum bounding boxes.
Post Reply