Any ideas how to use Python with the PIL module to shrink select all? I know this can be achieved with Gimp. I’m trying to package my app as small as possible, a GIMP install is not an option for the EU.
Say you have 2 images, one is 400×500, other is 200×100. They both are white with a 100×100 textblock somewhere within each image’s boundaries. What I’m trying to do is automatically strip the whitespace around that text, load that 100×100 image textblock into a variable for further text extraction.
It’s obviously not this simple, so just running the text extraction on the whole image won’t work! I just wanted to query about the basic process. There is not much available on Google about this topic. If solved, perhaps it could help someone else as well…
Thanks for reading!
If you put the image into a
numpyarray, it’s simple to find the edges which you can use PIL to crop. Here I’m assuming that the whitespace is the color(255,255,255), you can adjust to your needs:To show what the results look like, I’ve left the axis labels on so you can see the size of the
boxregion: