How can you use Imagemagick crop to get first 100px from an image?

It's been awhile since I've played with Imagemagick. I do remember crop and I can take an image named foo.png and use:

convert foo.png -gravity north -crop 1000x100 bar.png 

but my output is:

bar-0.png bar-1.png bar-2.png bar-3.png ... 

When I only want what's in bar-0.png.

I've researched around and found:

What is the correct way to crop an image and just get the first return? I'm not not worried about the aspect ratio or the size of the images. I'm just trying to get a sample of the image's first 100px.

1 Answer

You need to add the information from which X and Y you want to start, otherwise Imagemagick will repeat the crop:

convert foo.png -gravity north -crop 1000x100+0+0 bar.png 
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like