Cutting off the top portion of a page

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
damonm
Posts: 33
Joined: 2017-03-24T11:53:20-07:00
Authentication code: 1151

Cutting off the top portion of a page

Post by damonm »

Hey guys, I have searched the forum and found an article on cutting off the bottom 20% of an image but that didn't work for me. I have the image completely cropped and ready to go. This is a landscaped image, and I want to cut off the top 10 or 20% (I'll have to play with it to get it exact). I don't want to cut anything else except the top and I haven't figured out how to do this although I suspect it is pretty simple. Many thanks in advance for your help! I am using ImageMagick-7.0.5-4.x86_64.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cutting off the top portion of a page

Post by snibgo »

"-crop" will do this, eg:

Code: Select all

convert in.png -gravity South -crop x90%+0+0 +repage out.png
EDIT: Sorry, you use v7, so use "magick" instead of "convert".
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Cutting off the top portion of a page

Post by GeeMack »

damonm wrote: 2017-04-05T11:35:41-07:00This is a landscaped image, and I want to cut off the top 10 or 20% (I'll have to play with it to get it exact). I don't want to cut anything else except the top and I haven't figured out how to do this although I suspect it is pretty simple.
There are many ways to go about this, one of the more straightforward methods is by using "-crop" as snibgo described above. You can also use "-chop" or "-extent" just about as simply. Here are a couple of example commands...

Code: Select all

magick image.png -gravity north -chop 0x10% result.png

Code: Select all

magick image.png -gravity south -extent 100x90% result.png
Edited to add: Depending on the level of precision you require, all of those example operations can use fractions of whole percentages. Something like "-crop 100x90.3%+0+0" should work.
Post Reply