Crop image, clip out 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
boromb
Posts: 17
Joined: 2009-01-29T03:20:34-07:00

Crop image, clip out bottom of image

Post by boromb »

Hello,

I'm trying to extract bottom of a image to a new file.
The image is about 700width and 842 height.
I want to clip out 200 in height from bottom up.

convert.exe image.png -crop 700x200+0+842 +repage bottom.png

I get a new image but I don't feel that I'm doing this right because I get different from file to file.

Is that syntax right?

Best regards!
lwhistler
Posts: 23
Joined: 2010-09-15T15:33:29-07:00
Authentication code: 8675308

Re: Crop image, clip out bottom of image

Post by lwhistler »

x y starts at the top left of the images so 842 should be 842-200= 642 If you are bulk processing different size of images then you have loop through the image sizes to minus 200 from the height for the start position of the crop.


--------
Last edited by lwhistler on 2010-09-27T00:29:54-07:00, edited 1 time in total.
boromb
Posts: 17
Joined: 2009-01-29T03:20:34-07:00

Re: Crop image, clip out bottom of image

Post by boromb »

lwhistler wrote:x y starts at the top left of the images so 842 should be 842-200= 642 If you are bulk processing different size of images then you have loop through the image sizes to minus 200 from the height for the start position of the crop.


--------
Following syntax works much better. Is this right? :)

convert.exe image.png -gravity South -crop 700x200+0-50 +repage bottom.png

For some reason I need "-50" to get all of the bottom image. Otherwise ImageMagick doesn't
crop from the bottom.

How would your syntax look like?

Regards!
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Crop image, clip out bottom of image

Post by Drarakel »

Your command should work without "-50". But maybe some of your PNG files already have an offset. If you don't need these offsets anymore, then also add "+repage" at the start of your command:
convert image.png +repage -gravity South -crop 700x200+0+0 +repage bottom.png
boromb
Posts: 17
Joined: 2009-01-29T03:20:34-07:00

Re: Crop image, clip out bottom of image

Post by boromb »

Drarakel wrote:Your command should work without "-50". But maybe some of your PNG files already have an offset. If you don't need these offsets anymore, then also add "+repage" at the start of your command:
convert image.png +repage -gravity South -crop 700x200+0+0 +repage bottom.png
Works great!

Thank you very much!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Crop image, clip out bottom of image

Post by anthony »

The better ideal is to have that +repage before the final save in whatever it was that created those PNG images.

Typically it is caused by either a -crop, -trim or +distort, and is needed for special operations such as image layering, which is why these operations can generate offsets (usually to preserve some information about the image.

If it is unwanted it should have been removed immediately after those operations.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply