7

For example, I'd like to crop an area in this yellow rectangle in all pictures of same dimensions (same length and width).

Image

One use of this may be to crop a bunch of screenshots taken of a video game or program so that only the relevant parts of the image are there.

CaldeiraG
  • 2,623
  • 8
  • 21
  • 34

3 Answers3

10

You can use irfanview to do this. Once you have it installed, open a command prompt, go to irfanview program folder, then convert your images with a command like this:

i_view64.exe c:\images\*.jpg /crop=(0,0,500,500,0) /convert=c:\output\*.jpg 

The 5 numbers in the parenthesis are

  1. starting X position
  2. starting Y position
  3. width
  4. height
  5. which corner to start with.

you'll have to find these numbers yourself. Once you have the numbers figured out, you can crop all your images with the command above in one go.

Or if you prefer graphical user interface instead of command line, you can open up one of your images using irfarview, press b to batch crop/convert your files. you can find crop options by advanced button.

Giacomo1968
  • 58,727
SparedWhisle
  • 4,393
7

You can use the well known free and open-source ImageMagick

Simple example from the documentation:

convert rose: -crop 40x30+10+10  crop.gif

Where 40x30+10+10 is the geometry, basically meaning width x height + offsetX + offsetY. All in pixels. Offset is measured from top left corner. Note that there should be no spaces between the numbers and the x and + signs. I'm adding spaces here for readability.

To run that for a batch of images, you could use OS completion and expansion commands depending on which system you're on. In Windows command prompt for example:

for %f in (*.png) do (
    convert %f -crop 40x30+10+10 cropped_%f
)

In PowerShell:

gci *.png | %{ convert -crop 40x30+10+10 $_.FullName ($_.BaseName+"_crop"+$_.Extension)}

And in Bash:

images=$(ls -1 *.png)
for image in $images ; do
    convert -crop 40x30+10+10 cropped_$image
done

If you want to recurse through all sub-directories, use:

images=$(find -type f -name '*.png')
Giacomo1968
  • 58,727
Raf
  • 229
-1

https://www.thewindowsclub.com/free-image-splitter-software-for-windows

I used 2] and 4] for splitting large maps or satellite images.