1

I'm kind of in a hurry so I ask it here (I'll read the documentation later).

I have image files (width 1280, height 720, colored, jpg) and I want to first reduce the files to half both vertically and horizontally, to 640x360, and I want to cut 120 rows (upper 60 rows and bottom 60 rows) to make an 640x240 color image. I want the final format to be .ppm.

How can I do this using ImageMagick's convert command?

Edit: I found I can first reduce the image size to 640x360 using another tool, and then I can do:

convert -crop 640x240 filename.jpg filename_crop.jpg

to crop the lower 120 rows to get 640x240 .jpg files. I can use another tool (like web service) to convert them to .ppm files at least. But ImageMagick's manual isn't so kind. For example it says:

-define format:option
                     define one or more image format options 

but doesn't say anything about format:option.

1

1 Answer 1

0

The command you need is:

convert -resize 640x360\! -crop 640x240+0+60 filename.jpg filename_crop.ppm
  • The \! in -resize is used to resize to the specified size without keeping the aspect ratio of the image. If we don't add that, the image will resized to best fit the given size.

  • In the crop command, 640x240 (width*height) specify the cropped image's dimensions, while +0+60 (+left_offset+top_offset) specify the offset from the top left of the initial image. In this case, it crops the image with an offset of 60 pixels from the top.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.