Wikipedia:Reference desk/Archives/Computing/2018 November 8

Computing desk
< November 7 << Oct | November | Dec >> November 9 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


November 8

edit

I'm trying to use ImageMagick to crop a bunch of images of various sizes. I want to remove the leftmost 10% and the rightmost 10% of each image. Let's say the image is 1000 width by 1000 height, I want to remove the leftmost 100x1000 rectangle, and the rightmost 100x1000, so that I end up with an resulting image of 800 width by 1000 height. Reading its manual[1], this is seems easy to do using the -crop command if all the images sizes were identical, so that I can pre-calcuate the crop rectangle XY coordinates in advance. But when the input images have different dimensions, I can't seem to find a way to use percentage values to specify the crop rectangle size and location. Any and all help would be much appreciated. Mũeller (talk) 12:28, 8 November 2018 (UTC)[reply]

  • @Mũeller: The section you linked tells you see Image Geometry for complete details about the geometry argument. A bit more hunting finds that page, based on which I guess (without having tested it) that what you want is -gravity Center -crop 80x100%+0+0 image.out. It does not seem possible to specify offsets in percentages, but since you want to crop an equal amount left and right, you can crop "from the center". TigraanClick here to contact me 12:43, 8 November 2018 (UTC)[reply]
This post on the imagemagick forum gives some examples of how to crop offsets in percentages EniaNey (talk) 15:04, 14 November 2018 (UTC)[reply]
Thank you so much! That worked perfectly! Mũeller (talk) 15:19, 8 November 2018 (UTC)[reply]
  Resolved