Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch processing - detecting various colours to crop to edge of scanned document JPG?
#11
(06-30-2022, 11:40 AM)Ofnuts Wrote: There is no way in a script to see where you clicked. What a script sees is the result of click (for instance a selection, a path, or a guide).

If you always include the top left corner in the crop, click on the bottom right corner and drag beyond the top left one and Gimp will adjust that to the corner (make sure you have disabled "Allow growing" in the Crop tool options).

That's a bit of a shame that there can be no one-click "crop to this point" command, but at least you can start in the bottom-right corner and drag beyond the top-left without having to be accurate, according to what you say above. That means it isn't a fiddly, slow selection process.
Reply
#12
Maybe as a starter, Gimp can add a pair of guides at a point using the measure tool. Ctrl-Alt and a click-and-click again adds the guides. The bottom right corner.

To get those to crop, bound to be a better way but...

Add guides at the top left corner
Already have the guides bottom right corner
Make a selection from the guides
Invert selection and fill to remove the discolored border.
Zealous crop to the content.

In the zip two files, for_crop.py  Guides-to-selection-mk2.scm  the .py goes in your plugins folder / .scm in your scripts folder.

Still hands on, add your bottom-right guides, invoke the plugin Tools -> for_crop Make a keyboard shortcut (I used Z ) a bit quicker.

Example: https://i.imgur.com/oYi4TRG.mp4 about 40 seconds.

What it does not do is (1) Save/Export the image (2) move on to the next image, although Ofnuts has such a plugin. see: earlier post.

One for Ofnuts: Image -> Crop to Selection menu entry but not in pdb ?


Attached Files
.zip   for_crop.zip (Size: 1.51 KB / Downloads: 265)
Reply
#13
(06-30-2022, 12:09 PM)mkilpatr Wrote: That's a bit of a shame that there can be no one-click "crop to this point" command,
Because there would have to be 9 such "Crop to this point". Top left corner is your own personal case, but one can easily make a case for the three other corners, and then add the four middle of sides and the center. A useful interface isn't the addition of the needs of the million users, but a compromise between coverage and ease of access.
Reply
#14
(06-30-2022, 02:50 PM)rich2005 Wrote: One for Ofnuts:   Image -> Crop to Selection  menu entry but not in pdb ?

There has never been a one-to-one mapping between UI functions and the PDB. Some UI functions require two or more PDB calls (gimp_selection_bounds(image) & gimp_image_crop(image, new_width, new_height, offx, offy) for instance) but the opposite can also be true.
Reply


Forum Jump: