crop image only in height

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
razor74
Posts: 4
Joined: 2018-11-16T02:18:34-07:00
Authentication code: 1152

crop image only in height

Post by razor74 »

Hello,

I'm trying to crop image by height with this command line :

convert 1053257.png -gravity South -crop 2910x3312+0+0 -background black +repage image-cropped-top.png

the generated image is not cropped correctly the dimension after running command are 2791x3312
the width is cropped as well !!

can anyone help with this pls ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: crop image only in height

Post by snibgo »

Please tell us the version of IM you are using, and on what platform, and please paste a link to your input file.
snibgo's IM pages: im.snibgo.com
razor74
Posts: 4
Joined: 2018-11-16T02:18:34-07:00
Authentication code: 1152

Re: crop image only in height

Post by razor74 »

I'm using imagemagick version 6.9.10-Q16 on windows 10

Actually I trim the image first and then I do the crop

here the link to the image:
https://s3.eu-central-1.amazonaws.com/c ... inal-2.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: crop image only in height

Post by snibgo »

razor74 wrote:Actually I trim the image first and then I do the crop
So I expect you also "+repage" after the trim? Please show the exact command or series of commands you use. Otherwise we can only guess.

Inserting "+write info:" at various stages in your command can help with understanding what is happening.
snibgo's IM pages: im.snibgo.com
razor74
Posts: 4
Joined: 2018-11-16T02:18:34-07:00
Authentication code: 1152

Re: crop image only in height

Post by razor74 »

here the series of command I do:

convert original-1.png -trim original-1-trimmed.png
convert original-1-trimmed.png -gravity South -crop 2910x3312+0+0 +repage original-1-cropped-top.png
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: crop image only in height

Post by GeeMack »

razor74 wrote: 2018-11-16T07:30:27-07:00here the series of command I do:

convert original-1.png -trim original-1-trimmed.png
convert original-1-trimmed.png -gravity South -crop 2910x3312+0+0 +repage original-1-cropped-top.png
When you "-trim" an image it will remember the original page dimensions, then when you crop the image it uses those page dimensions as the starting reference for the crop. You need to "+repage" before the crop to start with fresh paging information. Try this...

Code: Select all

convert original-1.png -trim +repage -gravity South -crop 2910x3312+0+0 +repage original-1-cropped-top.png
razor74
Posts: 4
Joined: 2018-11-16T02:18:34-07:00
Authentication code: 1152

Re: crop image only in height

Post by razor74 »

Thanks a lot is solve my issue.
Post Reply