How to Cut Image by Top 30% in Unix Using ImageMagick

image manipulationimagemagickimages

I want to cut 30% from the top of the image.
I know the thread How to cut a really large raster image into smaller chunks? but there is no successful approach because I cannot find a distance measure of convert from zero to the end, only by absolute value dimensions.
Pseudocode

convert -crop-y -units-percentage 0x30 heart.png 

Fig. 1 Input figure

enter image description here

I can do the task with LaTeX's adjustbox but the output in the pdf file is not really end result but a presentation of it. So copying the image from the pdf document yields the original image.
So this approach failed.

Best Answer

You can crop a percentage of your image though in this case, to avoid running additional commands to get the image height and width (in order to calculate crop offset which by default is relative to top-left corner) you'll also have to crop relative to gravity (so that your crop offset position is relative to the bottom-left corner of the image):

convert -gravity SouthWest -crop 100x70%x+0+0 infile.jpg outfile.jpg
Related Question