What is the best way to auto crop bulk images?

  • I need to scan a large volume of book covers and even though the scanner (HP) most of the time scans/auto-sizes, many are left with white/grey space on the sides.

    What is the best way I can automate the "crop" on these images?

    Is there some software/tools that automate this?

  • ltn100

    ltn100 Correct answer

    10 years ago

    I'm not sure there are any tools that will completely automate this process, unless you're willing to write a custom script.

    I sometimes have to crop quite a few images at work, and one of the simplest tools that I have come across for this is a small image editor called IrfanView. It's not the prettiest of programs, but can do a crop and move on to the next picture with one mouse drag and three keystrokes. Here's how:

    • Install IrfanView and run the program.
    • Open the 'Options' menubar and select 'Properties/Settings...'
    • Select 'File Handling' from the list and uncheck the "Display 'Save'-Dialog" and "Ask to overwrite file for 'Save'" options.
    • Next, open the first image you want to crop.
    • Drag a square around the section to crop.
    • Press Ctrl+Y, Ctrl+S and then hit Space to move to the next image.
    • Repeat ad tedium.

    Looks like for my work, this is the only solution.

    It can't possibly be the *only* solution. There's a lot of software in the world, and this one seems (as it says) tedious.

    @mattdm: It depends on how on how difficult it is to perform the segmentation. If there is a simple rectangular border of a single colour then the cropping operation is trivial (in fact irfanview can perform this automatically with Ctrl+Shift+Y). But if there is noise in the border--or worse, clutter--then then the cropping is not that simple, and many algorithms can struggle and make mistakes. Having said that, I've not used _all_ software, so if anyone has a better solution then I'd be glad to hear it :-)

    This is a good solution but there are answers further down that actually provide the automation the OP was looking for.

    Irfanview can do batch operations, including Crop. Go to File > Batch conversion/Rename. Click the Advanced button and set your crop. Then select the images to work on, and click Start Batch.

    I'm almost sure that clutter, noise or similar in the "background" is actually the cause for the scanner software failing to auto-crop some of the images in the first place, thus almost any automatic tool for the task may face similar dificulties.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM