Page 1 of 1
How to crop 32 pixels at the top?
Posted: 2017-10-02T22:17:19-07:00
by bensto
As far as I know I can crop a picture to a height of 3000 pixels by the following command:
convert in.jpg -crop x9000+0+0 +repage out.jpg
However the cropped part is here always at the bottom of the picture.
How can I tell ImageMagick to only crop at the top of the picture?
How can I tell Imagemagick to crop 32pixels at the top regardless of how height the picture is in total?
How can I specify to crop 22 pixels at the top and 10 pixels at the bottom?
Ben
Re: How to crop 32 pixels at the top?
Posted: 2017-10-02T22:37:30-07:00
by snibgo
bensto wrote:As far as I know I can crop a picture to a height of 3000 pixels by the following command:
convert in.jpg -crop x9000+0+0 +repage out.jpg
No. If you want a height of 3000 pixels, ask for 3000, not 9000.
Precede with "-gravity" if you want, eg "-gravity North" to get rows from the top of the image, or South to get rows from the bottom.
To remove a certain number from the top or bottom, use "-gravity XX -chop". See
http://www.imagemagick.org/script/comma ... s.php#chop
Re: How to crop 32 pixels at the top?
Posted: 2017-10-03T09:51:31-07:00
by bensto
Thank you.
Is the chop operation lossless?
After applying
convert.exe test.jpg -gravity North -chop x160 +repage out.jpg
in the resulting picture the heaven seems to be much more blue than in the original.
Re: How to crop 32 pixels at the top?
Posted: 2017-10-03T09:54:58-07:00
by fmw42
Chop is lossless. The issue is that you are using jpg images. They are lossy compressed. So your image must be decompressed, chopped and recompressed and this will not be lossless.
Re: How to crop 32 pixels at the top?
Posted: 2017-10-03T09:57:39-07:00
by snibgo
"-chop" removes pixels. It doesn't change pixels.
Writing to JPEG is lossy. Pixels will change. But I doubt that "seems to be much more blue" comes from that. That's more likely to be an illusion.
Re: How to crop 32 pixels at the top?
Posted: 2017-10-06T06:20:28-07:00
by bensto
Thank you for clarification.
However after ImageMagick decompressed (internally) the *.jpg and applied the -chop command a re-compression takes place:
At which compression level (by default)?
Assume I want a compression level of 97%: How can I specify this in the convert command above?
Re: How to crop 32 pixels at the top?
Posted: 2017-10-06T06:30:04-07:00
by snibgo
JPEG compression is controlled by "-quality". See
http://www.imagemagick.org/script/comma ... hp#quality . This is a number from 1 to 100, but not a percentage.
Re: How to crop 32 pixels at the top?
Posted: 2017-10-06T06:37:37-07:00
by bensto
ok. Thx