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


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.

  • 1
    NetPBM (open source, multi-platform) is another solution. I've used it for this sort of task, multiple times.
    – TOOGAM
    Commented Feb 21, 2020 at 6:22
  • For the BOUNTY: Photoshop can record and replay actions So that's easy to do. But it's paid software, so let me know if this is applicable.
    – 1NN
    Commented Apr 16 at 21:08
  • BOUNTY: a different solution is to create one unique pdf file from your images, then use one of the free (or paid) tools available to crop all pages at once, and then export the images for each cropped page of the pdf. This might loose some quality though, depending on the image format you are using.
    – 1NN
    Commented Apr 16 at 21:15
  • @Gantendo Then it should be moved there, no?
    – endolith
    Commented Apr 16 at 23:00
  • @1NN Recording and replaying actions would be a kludgy way to do it, as would using an intermediate PDF.
    – endolith
    Commented Apr 16 at 23:01

3 Answers 3


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.

  • 1
    What's a good way to find the numbers to crop? Is there a software that lines up your picture in a pixel grid? Commented Feb 26, 2020 at 23:51
  • 2
    irfanview does that as well. Just open your image, drag your mouse to select an area, then you can see the size and location of your selection in the title. Commented Feb 27, 2020 at 0:30
  • Great got it. By the way for the corner to start with, are there 4 corners? (So 0 for top left, 1 for top right, 2 for bottom left, 3 for bottom right). I don’t understand that part. I just put 0 like your example and it cropped just fine, but I’d like to understand it. Commented Feb 27, 2020 at 1:11
  • 1
    I actually tested this myself. you are right, 0 is for top left, so you usually want that. 1 would be top right, so top right corner would have X index 0, top left corner would have the largest X index. Same rule goes for 2 and 3. Commented Feb 27, 2020 at 1:42

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

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

images=$(find -type f -name '*.png')


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

  • 2
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Commented Apr 23 at 5:13
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Apr 23 at 8:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .