| Hash | Commit message | Author | Date | Files | + | - |
1 | commit d1b7bbcebb7f7b9b36a0712fe82b0050e4fa1c55 |
2 | Author: Connor Etherington <[email protected]> |
3 | Date: Sat Feb 17 05:07:33 2024 +0200 |
4 | |
5 | Auto-Commit Update - 20240217 |
6 | --- |
7 | PKGBUILD | 4 +- |
8 | README.md | 2 +- |
9 | .../DEBIAN/control | 2 +- |
10 | .../postinst | 0 |
11 | .../usr/bin/lfp | 0 |
12 | .../usr/share/doc/lfp/README.md | 0 |
13 | .../usr/share/lfp/cleaner | 0 |
14 | .../usr/share/lfp/lfp | 0 |
15 | .../usr/share/lfp/lfp-functions | 0 |
16 | .../usr/share/lfp/lfp-icons | 0 |
17 | .../usr/share/lfp/lfpcd | 0 |
18 | .../usr/share/lfp/lfprc | 0 |
19 | ...-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Bin |
20 | .../usr/share/lfp/ocr/ocr.js | 0 |
21 | .../usr/share/lfp/ocr/package.json | 0 |
22 | .../usr/share/lfp/ocr/tesseract.js | 0 |
23 | .../usr/share/lfp/scope | 0 |
24 | .../usr/share/licenses/lfp/LICENSE | 0 |
25 | .../usr/share/man/man1/lfp.1.gz | Bin |
26 | usr/share/doc/lfp/README.md | 2 +- |
27 | usr/share/lfp/lfprc | 16 ++++++- |
28 | usr/share/lfp/ocr/ocr.js | 52 +++++++++++++++++---- |
29 | usr/share/lfp/ocr/package.json | 3 +- |
30 | usr/share/man/man1/lfp.1.gz | Bin 1916 -> 1916 bytes |
31 | 24 files changed, 66 insertions(+), 15 deletions(-) |
32 | |
33 | diff --git a/PKGBUILD b/PKGBUILD |
34 | index a880d47..d7c4810 100644 |
35 | --- a/PKGBUILD |
36 | +++ b/PKGBUILD |
37 | @@ -1,14 +1,14 @@ |
38 | # Maintainer: Connor Etherington <[email protected]> |
39 | # --- |
40 | pkgname=lfp |
41 | -pkgver=4.1.7 |
42 | +pkgver=4.2.0 |
43 | pkgrel=1 |
44 | pkgdesc='A wrapper for the lf file manager with in-terminal media previews, on-exit directory changing and much more' |
45 | license=('MIT') |
46 | arch=('x86_64') |
47 | install="lfp.install" |
48 | url="https://gitlab.com/a4to/lfp" |
49 | -depends=(lf zsh ffmpeg graphicsmagick openslide ghostscript bat fzf dunst dialog xsel lolcat python3 python-docopt python-pillow python-attrs libxres python-setuptools python-pip) |
50 | +depends=(lf zsh ffmpeg graphicsmagick openslide ghostscript bat fzf dunst dialog xsel lolcat python3 python-docopt python-pillow python-attrs libxres python-setuptools python-pip tesseract tesseract-data-eng) |
51 | conflicts=(lfp-git) |
52 | optdepends=( |
53 | 'nodejs: to make use of lfps built in node actions manager' |
54 | diff --git a/README.md b/README.md |
55 | index c3ebb2f..86acf22 100644 |
56 | --- a/README.md |
57 | +++ b/README.md |
58 | @@ -4,7 +4,7 @@ |
59 | ### `lfp` is a simple wrapper for the `lf` file manager, with built-in file, image, and video previews, as well as on-exit directory changing. |
60 | ### The program makes use of `ueberzug` to preview images, documents, and video thumbnails. Preview behavior can be altered by editing the *scope* file. |
61 | |
62 | -**Version: 4.1.7** |
63 | +**Version: 4.2.0** |
64 | |
65 | *** |
66 | |
67 | diff --git a/lfp-4.1.7-1-x86_64/DEBIAN/control b/lfp-4.2.0-1-x86_64/DEBIAN/control |
68 | similarity index 97% |
69 | rename from lfp-4.1.7-1-x86_64/DEBIAN/control |
70 | rename to lfp-4.2.0-1-x86_64/DEBIAN/control |
71 | index 38ac2e5..0246bb7 100644 |
72 | --- a/lfp-4.1.7-1-x86_64/DEBIAN/control |
73 | +++ b/lfp-4.2.0-1-x86_64/DEBIAN/control |
74 | @@ -1,5 +1,5 @@ |
75 | Package: lfp |
76 | -Version: 4.1.7 |
77 | +Version: 4.2.0 |
78 | Maintainer: © Connor Etherington <[email protected]> |
79 | Depends: lf, zsh, ffmpeg, graphicsmagick, openslide-tools, ghostscript, bat, fzf, dunst, dialog, xsel, lolcat, python3, python3-docopt, python3-pillow, python3-attr, libxres-dev, python3-setuptools, python3-pip, nodejs |
80 | Architecture: amd64 |
81 | diff --git a/lfp-4.1.7-1-x86_64/postinst b/lfp-4.2.0-1-x86_64/postinst |
82 | similarity index 100% |
83 | rename from lfp-4.1.7-1-x86_64/postinst |
84 | rename to lfp-4.2.0-1-x86_64/postinst |
85 | diff --git a/lfp-4.1.7-1-x86_64/usr/bin/lfp b/lfp-4.2.0-1-x86_64/usr/bin/lfp |
86 | similarity index 100% |
87 | rename from lfp-4.1.7-1-x86_64/usr/bin/lfp |
88 | rename to lfp-4.2.0-1-x86_64/usr/bin/lfp |
89 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/doc/lfp/README.md b/lfp-4.2.0-1-x86_64/usr/share/doc/lfp/README.md |
90 | similarity index 100% |
91 | rename from lfp-4.1.7-1-x86_64/usr/share/doc/lfp/README.md |
92 | rename to lfp-4.2.0-1-x86_64/usr/share/doc/lfp/README.md |
93 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/cleaner b/lfp-4.2.0-1-x86_64/usr/share/lfp/cleaner |
94 | similarity index 100% |
95 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/cleaner |
96 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/cleaner |
97 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/lfp b/lfp-4.2.0-1-x86_64/usr/share/lfp/lfp |
98 | similarity index 100% |
99 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/lfp |
100 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/lfp |
101 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/lfp-functions b/lfp-4.2.0-1-x86_64/usr/share/lfp/lfp-functions |
102 | similarity index 100% |
103 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/lfp-functions |
104 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/lfp-functions |
105 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/lfp-icons b/lfp-4.2.0-1-x86_64/usr/share/lfp/lfp-icons |
106 | similarity index 100% |
107 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/lfp-icons |
108 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/lfp-icons |
109 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/lfpcd b/lfp-4.2.0-1-x86_64/usr/share/lfp/lfpcd |
110 | similarity index 100% |
111 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/lfpcd |
112 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/lfpcd |
113 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/lfprc b/lfp-4.2.0-1-x86_64/usr/share/lfp/lfprc |
114 | similarity index 100% |
115 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/lfprc |
116 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/lfprc |
117 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/lfpreviewer-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl b/lfp-4.2.0-1-x86_64/usr/share/lfp/lfpreviewer-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
118 | similarity index 100% |
119 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/lfpreviewer-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
120 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/lfpreviewer-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
121 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/ocr/ocr.js b/lfp-4.2.0-1-x86_64/usr/share/lfp/ocr/ocr.js |
122 | similarity index 100% |
123 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/ocr/ocr.js |
124 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/ocr/ocr.js |
125 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/ocr/package.json b/lfp-4.2.0-1-x86_64/usr/share/lfp/ocr/package.json |
126 | similarity index 100% |
127 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/ocr/package.json |
128 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/ocr/package.json |
129 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/ocr/tesseract.js b/lfp-4.2.0-1-x86_64/usr/share/lfp/ocr/tesseract.js |
130 | similarity index 100% |
131 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/ocr/tesseract.js |
132 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/ocr/tesseract.js |
133 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/lfp/scope b/lfp-4.2.0-1-x86_64/usr/share/lfp/scope |
134 | similarity index 100% |
135 | rename from lfp-4.1.7-1-x86_64/usr/share/lfp/scope |
136 | rename to lfp-4.2.0-1-x86_64/usr/share/lfp/scope |
137 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/licenses/lfp/LICENSE b/lfp-4.2.0-1-x86_64/usr/share/licenses/lfp/LICENSE |
138 | similarity index 100% |
139 | rename from lfp-4.1.7-1-x86_64/usr/share/licenses/lfp/LICENSE |
140 | rename to lfp-4.2.0-1-x86_64/usr/share/licenses/lfp/LICENSE |
141 | diff --git a/lfp-4.1.7-1-x86_64/usr/share/man/man1/lfp.1.gz b/lfp-4.2.0-1-x86_64/usr/share/man/man1/lfp.1.gz |
142 | similarity index 100% |
143 | rename from lfp-4.1.7-1-x86_64/usr/share/man/man1/lfp.1.gz |
144 | rename to lfp-4.2.0-1-x86_64/usr/share/man/man1/lfp.1.gz |
145 | diff --git a/usr/share/doc/lfp/README.md b/usr/share/doc/lfp/README.md |
146 | index ea36087..2aa1340 100644 |
147 | --- a/usr/share/doc/lfp/README.md |
148 | +++ b/usr/share/doc/lfp/README.md |
149 | @@ -4,7 +4,7 @@ |
150 | ### `lfp` is a simple wrapper for the `lf` file manager, with built-in file, image, and video previews, as well as on-exit directory changing. |
151 | ### The program makes use of `ueberzug` to preview images, documents, and video thumbnails. Preview behavior can be altered by editing the *scope* file. |
152 | |
153 | -**Version: 4.1.7** |
154 | +**Version: 4.2.0** |
155 | |
156 | *** |
157 | |
158 | diff --git a/usr/share/lfp/lfprc b/usr/share/lfp/lfprc |
159 | index 1b36152..ea488c3 100755 |
160 | --- a/usr/share/lfp/lfprc |
161 | +++ b/usr/share/lfp/lfprc |
162 | @@ -499,8 +499,22 @@ cmd setbg "$1" |
163 | cmd bulkrename $vidir |
164 | |
165 | cmd ocr ${{ |
166 | - node /usr/share/lfp/ocr/ocr.js $fx |
167 | + result=${result:-} |
168 | + for x in ${fx[@]}; do |
169 | + node /usr/share/lfp/ocr/ocr.js $x |
170 | + result="$(cat << EOF |
171 | +$result |
172 | + |
173 | + |
174 | + |
175 | +$(basename $x): |
176 | +---------------- |
177 | +$(xsel -bo) |
178 | +EOF |
179 | + )" |
180 | + done |
181 | notify-send "🔧 OCR Complete" "Text copied to clipboard." |
182 | + [[ -n $result ]] && echo -e "$result" | awk '/./,EOF' | tac | awk '/./,EOF' | tac | less --use-color +% |
183 | }} |
184 | |
185 | |
186 | diff --git a/usr/share/lfp/ocr/ocr.js b/usr/share/lfp/ocr/ocr.js |
187 | index 4604522..bef2825 100755 |
188 | --- a/usr/share/lfp/ocr/ocr.js |
189 | +++ b/usr/share/lfp/ocr/ocr.js |
190 | @@ -3,7 +3,8 @@ |
191 | const fs = require('fs'); |
192 | const fsp = require('fs').promises; |
193 | const path = require('path'); |
194 | -const tesseract = require('./tesseract'); |
195 | +const scriptDir = path.dirname(require.main.filename); |
196 | +const tesseract = require(path.join(scriptDir, 'tesseract.js')); |
197 | const { spawn } = require('child_process'); |
198 | |
199 | const green = '\x1b[32m'; |
200 | @@ -26,19 +27,54 @@ let fail = false; |
201 | |
202 | const ocr = async (imagePath) => { |
203 | const Type = await sh(`file -b --mime-type ${imagePath}`); |
204 | - if (await sh(`file -bL --mime-encoding ${imagePath}`) === 'utf-8') { |
205 | - return await fsp.readFile(imagePath, 'utf8'); |
206 | + if(Type === 'PNG image data' || Type === 'JPEG image data' || Type === 'TIFF image data' || Type === 'image/x-portable-bitmap' || Type === 'image/png' || Type === 'image/jpeg' || Type === 'image/tiff' || Type === 'PC bitmap') { |
207 | + |
208 | + let binary = require('child_process').exec('which tesseract', (err, stdout, stderr) => { |
209 | + if (err) { |
210 | + console.error('\n\x1b[31m[-]\x1b[0m Fatal Error: Tesseract not found...'); |
211 | + process.exit(1); |
212 | + } |
213 | + if (stdout === '') { |
214 | + console.error('\n\x1b[31m[-]\x1b[0m Fatal Error: Tesseract not found...'); |
215 | + process.exit(1); |
216 | + } |
217 | + if (stderr) { |
218 | + console.error(stderr); |
219 | + process.exit(1); |
220 | + } |
221 | + }); |
222 | + |
223 | + const image = await fsp.readFile(imagePath); |
224 | + return await tesseract.recognize(image, config); |
225 | + |
226 | } else if (Type === 'PDF document') { |
227 | + |
228 | + let binary = require('child_process').exec('which tesseract', (err, stdout, stderr) => { |
229 | + if (err) { |
230 | + console.error('\n\x1b[31m[-]\x1b[0m Fatal Error: Tesseract not found...'); |
231 | + process.exit(1); |
232 | + } |
233 | + if (stdout === '') { |
234 | + console.error('\n\x1b[31m[-]\x1b[0m Fatal Error: Tesseract not found...'); |
235 | + process.exit(1); |
236 | + } |
237 | + if (stderr) { |
238 | + console.error(stderr); |
239 | + process.exit(1); |
240 | + } |
241 | + }); |
242 | + |
243 | await sh(`convert ${imagePath} -background white ${imagePath}.png`); |
244 | const res = await tesseract.recognize(`${imagePath}.png`, config); |
245 | await fs.unlinkSync(`${imagePath}.png`); |
246 | return res; |
247 | - } else if(Type === 'PNG image data' || Type === 'JPEG image data' || Type === 'TIFF image data' || Type === 'image/x-portable-bitmap' || Type === 'image/png' || Type === 'image/jpeg' || Type === 'image/tiff' || Type === 'PC bitmap') { |
248 | - const image = await fsp.readFile(imagePath); |
249 | - return await tesseract.recognize(image, config); |
250 | } else { |
251 | - fail = true; |
252 | - throw new Error('Unknown image type'); |
253 | + try { |
254 | + return await fsp.readFile(imagePath, 'utf8'); |
255 | + } catch (err) { |
256 | + fail = true; |
257 | + throw new Error('Unknown image type'); |
258 | + } |
259 | } |
260 | } |
261 | |
262 | diff --git a/usr/share/lfp/ocr/package.json b/usr/share/lfp/ocr/package.json |
263 | index 0b24c3c..bbbb8cd 100644 |
264 | --- a/usr/share/lfp/ocr/package.json |
265 | +++ b/usr/share/lfp/ocr/package.json |
266 | @@ -1,6 +1,6 @@ |
267 | { |
268 | "name": "lfp-ocr", |
269 | - "version": "0.2.0", |
270 | + "version": "0.2.1", |
271 | "description": "", |
272 | "main": "ocr.js", |
273 | "scripts": { |
274 | @@ -17,6 +17,7 @@ |
275 | "author": "Connor Etherington <[email protected]", |
276 | "license": "MIT", |
277 | "dependencies": { |
278 | + "node-tesseract-ocr": "^2.2.1", |
279 | "shx": "^0.3.4" |
280 | } |
281 | } |
282 | diff --git a/usr/share/man/man1/lfp.1.gz b/usr/share/man/man1/lfp.1.gz |
283 | index 9ccffdc..b180e48 100644 |
284 | Binary files a/usr/share/man/man1/lfp.1.gz and b/usr/share/man/man1/lfp.1.gz differ |