How to crop images in batch and then re-crop the same way

2

I am getting automatically generated screenshots of our application, some of which need cropping, since they may only relate to a pop up window or some small portion of the screen.

Is there some way I could open a new screenshot, set how it should be cropped, have it cropped, and then, let's say a month later, when there's a new version of the screenshot, crop it the same way as the previous version without having to manually set the cropping area again?

In other words, I'm looking for a way to manage a "cropping project" encompassing a bunch of screenshots of the same size (1920x1080) at the source, but different size at the output due to the cropping.

So, input is always 1920x1080, but I should be able to say:

  • Crop some area from image A and save it as JPG
  • Crop another area from image B and save it as JPG
  • etc

and this should be done automatically based on some definition of the cropping, so that when I change the input images, I shouldn't have to re-do the cropping manually. Is this possible?

Ondrej

Posted 2015-04-27T13:13:49.593

Reputation: 165

If you want to screenshot just the popup, why not use alt-print screen feature which makes a screenshot of just the popup and stores that into your clipboard? (I know this does not answer your question, which is why this is a comment). Also, most screenshot programs can screenshot the active window (a popup for exaample) and stores that to an image for you. Greenshot (free program) does it too. – LPChip – 2015-04-27T13:24:07.897

the screenshots are generated automatically, so I cannot change the fact that the source screenshot takes full screen. There's a lot of them, and in several language versions, so automating this is very benefitial – Ondrej – 2015-04-27T13:35:52.140

1You can do this in Adobe Photoshop. It's called batch processing. You complete "actions" against a folder of images and it applies the actions to the images. You could "record" your cropping actions and replay them against the new screenshots. Assuming the application layout didn't change position. – skub – 2015-04-27T13:47:29.450

right! this didn't occur to me. – Ondrej – 2015-04-27T14:00:05.720

You want me to make an "answer" outlining that? – skub – 2015-04-28T00:57:41.323

After all, negative. I realized you probably understood my problem another way (or maybe I didn't explain it well). I know about the actions in photoshop and about the possibility to record those. But as far as I know, then each time I would want to renew the screenshot, meaning capture it again and crop it again, I would have to manually open it in PS, select the recorded crop and then finish. This wouldn't be practical because I would literally have hundreds of recorded croppings to choose from and it would be very labor intensive. I would like to automate this somehow on a filename basis. – Ondrej – 2015-07-01T07:43:10.713

Answers

0

There are many applications that will crop images in a "batch" mode. Without knowing your operating system, it is difficult to list them.

However, if you look for ImageMagik, you should find something for your platform.

Tools like this allow you to select images by name, size, etc and run the same transform on them.

Julian Knight

Posted 2015-04-27T13:13:49.593

Reputation: 13 389

Yes, I know this is possible, but I need the images to be various cutouts of various sizes from the original images. I've edited the initial post to reflect this (see the last paragraph with the bulletpoints). – Ondrej – 2015-05-05T13:12:05.723

If you change the input files, would they have the same name? – Julian Knight – 2015-05-05T15:51:10.373

Positive, they would. – Ondrej – 2015-05-11T10:13:21.827

Then all you need is to create a batch/shell script with the names. This is what imagemagik is for. Every time you update the files, rerun the script. If only some of the files change at any one time, you will need to keep track of the last run date/time and only run against files with a newer date/time. You can even use im to check the images for their original sizes and process accordingly if you like. – Julian Knight – 2015-05-11T20:55:46.457

You're right. But is there any way I could avoid having to specify the numbers (x-y offsets and width-height) of the crop settings manually? Is it possible to somehow do this let's say by displaying the image, making a selection of it while imagemagick would then compute these coordinates? – Ondrej – 2015-07-01T07:19:06.817

You seem to want to mix interactive and batch actions so I'm not sure what you want. If you want to crop visually then use display from imagemagick/graphicsmagick but I think you would have to go through every image individually that way. Or do one and make a note of the required parameters and do the rest in batch.

– Julian Knight – 2015-07-01T09:07:21.510