Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script to auto-rotate images to align with text flow?
#1
Tried search string on the forum:

Quote:Script auto rotate image text flow document

Had been thinking for many years: if an image of a text document could automatically be oriented along the textflow.

I self-learnt some programming out of curiosity. Very elementary programs. I don't have the patience, persistence, or hyper-focus of a programmer. 

Had been thinking in terms of drawing a set of two parallel lines apart from the middle towards the edges, and the maximum number of longest uninterrupted straight line segments that could be drawn between those two parallel lines (from one edge of an image to the opposite edge is quite superfluous) could help auto-orient a document along the direction of the text flow?

Perhaps this is the reason why OCR programs such as Abbyy Finereader could automatically rotate scanned documents?

But have left using Doze and associate programs. Have gscan2pdf and gimagereader. They are nothing compared to Abbyy of 10 years back. But who knows, in the name of PROPRIETARY, what malware/spyware/trojan might have they been inserting, in addition to  regular paid upgradation of Doze and anti-virus, anti-malware and what not software? So I am better off with bits and pieces solution and better safety and security with Free and OSS system.

Is there a script to achieve this very purpose? Auto-rotate such a file to horizontally align the direction of the flow of text with the help of a scirpt? Or any other tool?

Any advice please?

In the end another request: if the post isn't found appropriate for this forum, may I please be sent a copy before deleting it.
Reply
#2
There used to be a "deskew" plugin for this. AFAIK it does it by computing a 2D Fourier transform of the document. The resulting image has "spikes" at privileged angles that correspond to the general slant of the text, from which you can deduce a corrective rotation.

If you use any program (free or not) that has a sufficient number of users, paying or not, open source or not, it can be reasonably considered safe (or at least that the holes are either well know or benign). Nasties don't remain unspotted form long in such programs.

Open Source doesn't always mean safety. Quite the contrary, since it is very easy to make something that looks like the regular app, but with nasty additions to the code. FOSS is safe if you build it from the published source(*), or if you get it from a trusted builder (for instance, your distro's repositories if you use Linux). Gimp is safe if you download it from gimp.org. If you get it from somewhere else you don't really know what is inside. Of course there are alternative builders (such as Partha) that have acquired the community's trust over the years.

(*) And even then, there have been cases of hackers poisoning the source code of apps and libraries(**). But they ar usually quite quickly spotted.
(**) Not mentioning the NSA slightly skewing the random generators in Linux to make encryption a bit weaker;
Reply
#3
@bkpsusmitaa It would help if you gave details about the version of linux you use and the version of Gimp. In another post give debian and Knoppix but.. The latest versions of Debian and Knoppix (9.1) have versions of Gimp (2.10.22) that do not support gimp-python. That leaves script-fu solutions. If you do get any answers to the problem they might come in a Gimp python plugin form, although there are flatpak / appimage versions of Gimp to overcome that problem.

To give a bit of scope to the problem, these thumbnails pulled from an example PDF. Pages typically about 1400 x 1000 pix.

   

@Ofnuts I put the linux deskew binary in another post along with the divide scanned images script. Then found out the images are scanned pages. I recall the straighten script, must be in my archive somewhere. recall wrong. The deskew plugin shows up bottom the Layer -> Transform menu.
Reply
#4
(06-08-2021, 12:05 PM)rich2005 Wrote: @bkpsusmitaa  It would help if you gave details about the version of linux you use and the version of Gimp...
I don't use the latest editions. In general keep the ones that's working.
Debian 9.11.0
Knoppix 8.6
GIMP 2.8.18
I am not into high-end computing. Just an author and watch YT videos.
Thank you for considering my post appropriate and posting here.

In the meanwhile the test files in two-page format has been split up into one page manually and uploaded.
Reply
#5
(06-08-2021, 12:33 PM)bkpsusmitaa Wrote:
(06-08-2021, 12:05 PM)rich2005 Wrote: @bkpsusmitaa  It would help if you gave details about the version of linux you use and the version of Gimp...
I don't use the latest editions. In general keep the ones that's working.
Debian 9.11.0
Knoppix 8.6
GIMP 2.8.18
I am not into high-end computing. Just an author and watch YT videos.
Thank you for considering my post appropriate and posting here.

In the meanwhile the test files in two-page format has been split up into one page manually and uploaded.

There is a difference between "not the latest" and "trailing edge". Gimp 2.10 is significantly more usable than 2.8 (most filters act directly on the canvas, for instance, instead of the tiny preview window). Having Gimp no longer working in high precision (which has the side efcet of also not doing computations on gamma-corrected values) also fixed a number of issues.
Reply
#6
(06-08-2021, 12:33 PM)bkpsusmitaa Wrote: ...
In the meanwhile the test files in two-page format has been split up into one page manually and uploaded.

For anyone interested in the files to straighten by script they are in a tar archive here:
https://drive.google.com/file/d/1mTxCP7w...nFvmR3lzxJ
Reply
#7
(06-08-2021, 03:54 PM)rich2005 Wrote: For anyone interested in the files to straighten by script they are in a tar archive here ...

Thank you very much indeed for really helping out in this regard,

(06-08-2021, 03:00 PM)Ofnuts Wrote: ... There is a difference between "not the latest" and "trailing edge". Gimp 2.10 is significantly more usable than 2.8 ...

Upgradation is time-consuming and hard work. We haven't a support system on Linux in India.

---
please no politics, keep the topic on Gimp
rich
---
Reply


Forum Jump: