It is currently 03 Apr 2020, 04:33


GIMP/GL:  Tutorials | Tips | Questions | Interests | 🡆 Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Cropping script - small changes needed

Post your Script Requests for GIMP here.
Forum rules
Request your Script(s) for GIMP here in this forum.
Provide details of steps performed in GIMP so that script can be written for the process and also give the request a name so that scripts can be named after.
No avatar
wvanoeveren
Forum Member

Cropping script - small changes needed

Post#1 by wvanoeveren » 05 May 2019, 16:51


Hello,

Let me start to say hi to everyone ! I hope to be here more & more because i'm really seeing a lot of options for my projects on using GIMP scripting.

I recently was searching for a good solution to do some autocropping. I found a script on the net that is really good & close to what i need but i have to do some small changes on it. Since i'm really new to the whole scripting thing i've been searching for quite some time but i can't find what i'm looking for (probably because it is completely new and i'm searching on the wrong places or terms). So that is why i wanted to ask you guys some help. Let me explain what i'm after:
For custom projects we need to scan really old books. These books are very sensitive so we have to open them up and scan them really carefully. This means that we cannot move them all the time to put things in the right angle or location towards the camera. This means that the books are scanned with a black background but are not always exactly on the same location. Therefor i need the cropping part that detects the border and adds an extra border/padding to it. The script i found on the net is very close to the needs but it is lacking only small parts. For example: we are reading images in TIFF uncompressed format (grayscale - 8 bit - Phase One 2.2 layer, no thumbnails) and we need, after cropping, exactly the same image format. This is exactly what is missing on the script and which makes it at this moment not usable for me. I cannot find the right way on how to take the input image format (read it out?) and then, on the saving part, use exactly the same properties.
The script i found can be found on the web. Since i'm new i guess that is the reason why i cannot post urls here so i try to describe the url where you can find the script: search for "francois malan" and "batch crop" and you will arrive to the page --> below in the webpage you can find the link to the script called "DivideScannedImages". This is the one i'm talking about. I changed already the padding part (needs to be a bit more than 100 pixels) and this works. But it would be good if the original image format properties could be maintained.
One extra thing that would be needed is the original filename that is maintained as well for cross reference, maybe with just and addition of _crop_.

Can someone help me out on this please ?

Thanks !!
GIMP Learn rocks...
0

tim
GL Blogger

Post#2 by tim » 05 May 2019, 17:00


Hi, Welcome to GL forum!
Can you post a few examples of your original scanned pages? I am not sure what you mean by black background.
Like page is black and text is white? or it is border with black and page content is still white or lighter color.
I have moved you into forum member's group so that you now post attachments and post links.
Post a few examples so we (I) can try to come up with something for you.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

No avatar
wvanoeveren
Forum Member

Post#3 by wvanoeveren » 05 May 2019, 18:02


tim wrote:
05 May 2019, 17:00
Hi, Welcome to GL forum!
Can you post a few examples of your original scanned pages? I am not sure what you mean by black background.
Like page is black and text is white? or it is border with black and page content is still white or lighter color.
I have moved you into forum member's group so that you now post attachments and post links.
Post a few examples so we (I) can try to come up with something for you.
Hello!
Thanks for getting back to me!
I've uploaded some examples to wetransfer because of the filesize. Here is the link : https://we.tl/t-RM58dSOMJE
Hope this works out for you !

Thanks,
Wim
GIMP Learn rocks...
0

tim
GL Blogger

Post#4 by tim » 05 May 2019, 20:42


Please give this: viewtopic.php?f=3&t=2364
a test.
No padding yet as I am not sure what exact padding you want.
I suggest you test with 5 or so files in a folder first and confirm that it works correctly.
Let me know and details about padding to be added like constant 100px wide padding around the edges? of what color? or do you want the padding to change dynamically so that all finished cropped and padded images will end up with same size?
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

No avatar
wvanoeveren
Forum Member

Post#5 by wvanoeveren » 06 May 2019, 03:19


tim wrote:
05 May 2019, 20:42

a test.
No padding yet as I am not sure what exact padding you want.
I suggest you test with 5 or so files in a folder first and confirm that it works correctly.
Let me know and details about padding to be added like constant 100px wide padding around the edges? of what color? or do you want the padding to change dynamically so that all finished cropped and padded images will end up with same size?
Thanks Tim ! Much much much appreciated ! i will test it later first thing :)
about the padding : the purpose is to have a fix value everywhere but one that i can choose. In the script that i found the max value was 100px but in the current project the customer wants a fixed padding of about 3cm (so about 115px, slightly more).

thanks !
GIMP Learn rocks...
0

tim
GL Blogger

Post#6 by tim » 06 May 2019, 03:28


so make the plug-in accept a padding border-width input and a color that you choose of your choice?
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

No avatar
wvanoeveren
Forum Member

Post#7 by wvanoeveren » 06 May 2019, 03:33


tim wrote:
05 May 2019, 20:42
No padding yet as I am not sure what exact padding you want.
I suggest you test with 5 or so files in a folder first and confirm that it works correctly.
Let me know and details about padding to be added like constant 100px wide padding around the edges? of what color? or do you want the padding to change dynamically so that all finished cropped and padded images will end up with same size?
Hey Tim,

I'm back already (couldn't wait to test it out! haha!) and yes, it works perfectly !! this is exactly what i need :)
So i'm super excited to the the padding thing so i can test it out on some big batches of scans. What is for you the best way to use this in "background process"? The purpose is that i can start this process in a specific step in the flow so we can get to the point that all images will be cropped after scanning.
Btw: did you see the deskew option in the previous script? Not sure if you kept this or not but that would be a lifesaver too since, as described in my initial message, the books are not always scanned in the exact right angle.

Thanks !
Wim
GIMP Learn rocks...
0

tim
GL Blogger

Post#8 by tim » 06 May 2019, 04:04


Deskew, (straighten as I call it can be applied but it takes a really long time to search because the image is huge) If you don't mind waiting for long time.
I just added padding option and border as version 2....let me add a version 3 which will try to straighten it (even though its slow so you can try it out too).
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

tim
GL Blogger

Post#9 by tim » 06 May 2019, 04:18


Try version 3 it's not as bad I thought when I reduce straighten accuracy search down to 1 degree accuracy and search between -15/+15 degrees range.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

tim
GL Blogger

Post#10 by tim » 06 May 2019, 04:21


I am not too sure about background process... I would just scan a batch of say 100 and then run this per batch or so.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0


GIMP/GL:  Tutorials | Tips | Questions | Interests | 🡆 Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply
  • Similar Topics
    Replies
    Views
    Last post
• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

Who is online

Users browsing this forum: No registered users and 4 guests