Gimp-Forum.net
Scanned Page Processing Script - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Scanned Page Processing Script (/Thread-Scanned-Page-Processing-Script)



Scanned Page Processing Script - Gimpy222 - 12-24-2019

I have hundreds of scanned pages from a large 100 year old book that need sized consistently. I'm using Gimp 2.8.10

Currently I select the portion of the page left to right that has text and the very edge of the page top and bottom.

I then select grow by 250 pixels

then crop to selection

then canvas size 2000 px by 3300 px, CENTERED

then mode grayscale

then levels 50, .5, 200

the result is exactly what I need

I don't know anything about writing scripts. Can this all be done with a single click after the selection is made? If so, how?

Thanks Sandy


RE: Scanned Page Processing Script - Ofnuts - 12-24-2019

Yes, but why do you grow the selection (vs making that selection directly)? Is the initial selection close to the text and this adds margin?

With a click, no, but with a keystroke once you have set up a shortcut, yes... Can you post a sample page?


RE: Scanned Page Processing Script - Gimpy222 - 12-24-2019

(12-24-2019, 10:59 PM)Ofnuts Wrote: Yes, but why do you grow the selection (vs making that selection directly)? Is the initial selection close to the text and this adds margin?

With a click, no, but with a keystroke once you have set up a shortcut, yes... Can you post a sample page?

Thank you for your reply.

Yes the selection is to the exact edge of the text. This process adds perfect margins. It's difficult to make a 2000 x 3300 selection directly with the text area centered left and right. By selecting the text block and growing 250 then sizing to 2000 X 3300, the text is perfectly centered left and right. Top and bottom margins very close to original page.

Sandy


RE: Scanned Page Processing Script - Ofnuts - 12-24-2019

Sample image?


RE: Scanned Page Processing Script - Gimpy222 - 12-25-2019

Highly degraded images to meet 500kb max file size

[attachment=3677]

selection

[attachment=3678]

grow 250

[attachment=3679]

crop to selection

[attachment=3680]

canvas size 2000 X 3300 - centered

[attachment=3684]

desired margins

[attachment=3685]

grayscale then levels 50, .5, 200

[attachment=3686]

Final result. (looks much better using original image)

[attachment=3687]


RE: Scanned Page Processing Script - Ofnuts - 12-25-2019

Here it is... for installation instructions see here, in the "Installation" section at the bottom.

The filter can be found as Filters>Enhance>Crop and enhance but is best assigned to a keystroke with Edit>Keyboard shortcuts (find it by entering "gimpy222" in the search bar).

Three remarks:

  1. If you look at the script code, you'll notice it just does an (adequately computed) crop. The result is identical to the one obtained with your workflow, which in the end is just a way to have a 2000*3300 crop of the image with the initial selection centered in it.
  2. On the page with the installation instructions you will find ofn-file-next. This script can be a great time saver when mass-processing images, since it does "export image, close image, open next image in sequence" in one single operation (and is best assigned to a keystroke), which is where one usually spends the more time when doing simple processing on many files.
  3. Your images look professionally scanned/photographed so the cropping should be rather constant (or subject to a regular drift that can be easily compensated) among left-hand and right-hand pages. This would allow a completely automated batch-cropping.
Enjoy, and Merry Christmas.


RE: Scanned Page Processing Script - Gimpy222 - 12-25-2019

Thank you so much. Works like I need, except errors on the Levels bit.

This line maybe:

pdb.gimp_drawable_levels(layer,HISTOGRAM_VALUE,levelsBlack/255.,levelsWhite/255.,False,levelsGamma,0.,1.,False)

[attachment=3689]


RE: Scanned Page Processing Script - Ofnuts - 12-25-2019

What version of Gimp are you using? See attached, modified to work with Gimp 2.8


RE: Scanned Page Processing Script - Gimpy222 - 12-26-2019

Yes Gimp 2.8

Works perfect. Thank you very much.

Sandy