Page 1 of 1

crop image only in height

Posted: 2018-11-16T02:32:04-07:00
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 ?

Re: crop image only in height

Posted: 2018-11-16T06:23:38-07:00
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.

Re: crop image only in height

Posted: 2018-11-16T07:06:59-07:00
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

Re: crop image only in height

Posted: 2018-11-16T07:16:16-07:00
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.

Re: crop image only in height

Posted: 2018-11-16T07:30:27-07:00
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

Re: crop image only in height

Posted: 2018-11-16T08:06:57-07:00
by GeeMack
razor74 wrote:
2018-11-16T07:30:27-07:00
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
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

Re: crop image only in height

Posted: 2018-11-19T01:51:34-07:00
by razor74
Thanks a lot is solve my issue.