How to resize the content of an image in GIMP to a standard size

gimp

I'm working with scanned forms in GIMP. Though the form is the same, they are often scanned at different magnifications.

I would like to select the contents of the form (printed area excluding white space borders) and paste it to a uniform size (say 8.5×11"). So smaller images will be enlarged upon pasting and larger images will be shrunken to the proper size.

Selecting is easy to do using the "select by color" tool, but pasting in this "standardized way" is what I can't figure out.

Here is an example form:
Exmple Form

Also, this will eventually be automated (hopefully) through macros so I'm working under the assumption that If I can do this in the UI, it can be automated.

Best Answer

I actually do something similar every month for my lunch expenses, with receipts of various formats.

  • I take pictures of all the receipts using a fixed camera, so the receipts have a varying size inside the frame
  • I mass-process the images in Gimp:

    • Crop tool to crop the image to the receipt (one mouse drag, one double-click). For your specific purpose you can set the crop tool to have a fixed ratio.
    • Save picture and load next in sequence (this is a single keystroke, once you ave installed the ofn-file-next script and set up a shortcut)

    This takes a few seconds per image, so you process a hundred images in 5 minutes.

  • Once I have the cropped images on disk, I use ImageMagick in a shell script to set them all to the same size:

#! /bin/bash

dir=${1:-.}

for f in "$dir/"*.JPG; 
do
        echo "Processing $f"
        convert "$f" -resize 600x -sharpen 0x1.0 -quality 85 "$dir/$(basename "$f" .JPG).jpg"
done

Warning: the script above assumes that the input images are JPG, and that the filesystem is case-sensitive

ImageMagick is also available for Windows (but of course you have to adapt the script above for BAT or Powershell).