How can I crop multiple regions from one image and save them as separate numbered files in GIMP?
Asked 1/27/2020
6 views
2 answers
0
I need a faster way to extract many rectangular areas from a single photo and save each one as its own image file. In GIMP, I currently crop, save, and undo repeatedly, but some photos need 20+ crops and I have hundreds of images to process.
Ideally, I want to draw several boxes on one image, then export each box as a separate file with sequential names like birds1.jpg, birds2.jpg, and birds3.jpg. Free software is fine, but a GIMP-based solution would be best.
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
6y ago
2 Answers
2
Possible solution, using the ofn-extract-objects script found here(*):
- Make a multi-rectangle selection, one rectangle around each object (shift-click to add rectangles)
- Copy/paste the selection to a new layer: Ctrl-C, Ctrl-V, Ctrl-Shift-N. This layer will be mostly transparent, except where you selected things.
Layer>Extract objects>Extract object to filesthat will extract each opaque rectangle to a file in the specified directory. The script lets you define a naming pattern for the objects (from the image name, layer name, position of objects, etc...)
(*) See bottom of page for install instructions. The ZIP contains an HTML doc.
Originally by user75947. Source · Licensed CC BY-SA 4.0
user75947
6y ago
0
Generated from our catalog & community — verify before relying on it.
Yes—GIMP can do this with the ofn-extract-objects script.
Workflow:
- Make a multi-rectangle selection, adding one rectangle per object/area.
- Use Shift while selecting to add more rectangles to the same selection.
- Copy and paste the selection to a new layer (
Ctrl+C,Ctrl+V, then create/anchor to a new layer). - That new layer will be transparent except for the selected regions.
- Run Layer > Extract objects > Extract object to files.
The script exports each opaque rectangle as a separate file in the folder you choose. It also supports naming patterns based on the source image name, layer name, object position, and similar options, so you can generate sequential or structured filenames.
For your example, you could select each bird, put those selections on a new layer, and have the script save them as separate image files instead of manually cropping and undoing each time.
Recommended products
UniqueBot
AI6y ago
Your Answer
Related Questions
How do I combine all frames from a video into one light-painting image?
Why do most cameras use sequential filenames instead of date/time names?
How can I scan both sides of rigid postcards without bending them?
Why is my Nikon saving both JPG and NEF files, and how do I stop it?
Can Darktable overwrite original JPEGs after editing?