Break image into thirds keeping center third

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
abduct
Posts: 20
Joined: 2016-03-22T17:07:45-07:00
Authentication code: 1151

Break image into thirds keeping center third

Post by abduct »

I have images where the main detail is in the center of the image such as: https://i.imgur.com/6PzX9mX.jpg

And I want to crop off the left and right side by 1/3 each leaving only the center third of the image resulting in a image that is tall and narrow: https://i.imgur.com/oDhnRpr.png

Likewise after the cropping is done I want to resize it to 1312x2560 maintaining aspect ratio without damaging the quality of the image. The images vary in width and height most of which being 1920x1080. I will be going through the images for blurriness/artifacts by hand to choose the best ones to use.

The resizing can be done before or after the cropping.

This should be done in a way for bulk images to be modified. I believe mogrify is the correct tool for this. Images can be overwriten in the current directory or saved to a new directory. I am on Windows using ImageMagick-7.0.3-7-portable-Q16-x64 although I can upgrade the install if needed.

The purpose of this is to create cell phone backgrounds from images that are too wide for the screen.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Break image into thirds keeping center third

Post by GeeMack »

abduct wrote: 2017-12-03T15:25:01-07:00And I want to crop off the left and right side by 1/3 each leaving only the center third of the image resulting in a image that is tall and narrow: https://i.imgur.com/oDhnRpr.png

Likewise after the cropping is done I want to resize it to 1312x2560 maintaining aspect ratio without damaging the quality of the image. The images vary in width and height most of which being 1920x1080. I will be going through the images for blurriness/artifacts by hand to choose the best ones to use.

The resizing can be done before or after the cropping.
A command like this will remove the left and right thirds, leaving the vertical center 33.333%, and will process all the PNG images in the current directory.

Code: Select all

magick mogrify -gravity center -extent 33.333%x100% *.png
That will overwrite all the original PNGs, so use caution.

Add "-resize 1312x2560" after the "-extent" operation to resize the images to a maximum of 1312 pixels wide or 2560 pixels high, while still maintaining the aspect.
abduct
Posts: 20
Joined: 2016-03-22T17:07:45-07:00
Authentication code: 1151

Re: Break image into thirds keeping center third

Post by abduct »

Perfect this is exactly what I was looking for!

I couldn't figure out why chop, crop, and shave were giving me weird results. I never heard of extent before. At least I learned something new.
Post Reply