Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scanned Page Processing Script
#1
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
Reply
#2
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?
Reply
#3
(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
Reply
#4
Sample image?
Reply
#5
Highly degraded images to meet 500kb max file size

   

selection

   

grow 250

   

crop to selection

   

canvas size 2000 X 3300 - centered

   

desired margins

   

grayscale then levels 50, .5, 200

   

Final result. (looks much better using original image)

   
Reply
#6
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.


Attached Files
.zip   crop-and-enhance.zip (Size: 1.36 KB / Downloads: 180)
Reply
#7
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)

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


Attached Files
.zip   crop-and-enhance.zip (Size: 1.4 KB / Downloads: 182)
Reply
#9
Yes Gimp 2.8

Works perfect. Thank you very much.

Sandy
Reply


Forum Jump: