# File Uploader and OCR

**URL:** <https://discourse.joplinapp.org/t/file-uploader-and-ocr/719>\
**Category:** Apps\
**Created:** [25 September 2018 16:56 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719 "2018-09-25T16:56:43Z")\
**Posts on this page:** 20\
**Page:** 8

<div class="post-metadata">

**Author:** ![mzguy](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/mzguy/32/5520_2.png) [@mzguy](https://discourse.joplinapp.org/u/mzguy)\
**Post date:** [9 March 2021 19:41 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/142 "2021-03-09T19:41:23Z")

</div>

I got it figured out, so never mind the question. Thanks for the venv suggestion.

---

<div class="post-metadata">

**Author:** ![myfta](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/myfta/32/8201_2.png) [@myfta](https://discourse.joplinapp.org/u/myfta)\
**Post date:** [13 April 2021 08:16 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/143 "2021-04-13T08:16:19Z")

</div>

Not sure if this is the best place to post this. Whilst I was catching up with how to use Tesseract with Joplin the two posts illustrate the importance of optimising the image _before_ trying to OCR. If not done so already, maybe these ideas need to be carried through to the plugin developments?

[https://levelup.gitconnected.com/a-beginners-guide-to-tesseract-ocr-using-pytesseract-23036f5b2211](https://levelup.gitconnected.com/a-beginners-guide-to-tesseract-ocr-using-pytesseract-23036f5b2211)

> **[How to Use Tesseract on Windows](https://medium.com/@ahmetxgenc/how-to-use-tesseract-on-windows-fe9d2a9ba5c6)**
>
> Tesseract is an optical character recognition software which developed by Google. Its an open source OCR tool. There are many versions of…

---

<div class="post-metadata">

**Author:** ![mzguy](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/mzguy/32/5520_2.png) [@mzguy](https://discourse.joplinapp.org/u/mzguy)\
**Post date:** [13 April 2021 20:27 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/144 "2021-04-13T20:27:14Z")

</div>

I'm getting frequent cases of attachments that don't have any text recognized, even when the text is already there from running Tesseract on the file! I can send an example if anyone can debug.

---

<div class="post-metadata">

**Author:** ![manouchk](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/manouchk/32/6505_2.png) [@manouchk](https://discourse.joplinapp.org/u/manouchk)\
**Post date:** [11 June 2021 17:56 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/145 "2021-06-11T17:56:13Z")

</div>

THis plugin is not yet available in the official plugins list? I search for OCR and uploader in joplin and the plugin was not found.

---

<div class="post-metadata">

**Author:** ![JackGruber](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/jackgruber/32/3231_2.png) [@JackGruber](https://discourse.joplinapp.org/u/JackGruber)\
**Post date:** [11 June 2021 18:12 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/146 "2021-06-11T18:12:25Z")

</div>

This is no plugin for Joplin, this is a external script.

---

<div class="post-metadata">

**Author:** ![manouchk](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/manouchk/32/6505_2.png) [@manouchk](https://discourse.joplinapp.org/u/manouchk)\
**Post date:** [12 June 2021 11:16 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/147 "2021-06-12T11:16:10Z")

</div>

Thank you. I have a strange error when trying to configure token:

```auto
/usr/lib/python3.9/site-packages/rest_uploader/api_token.py in get_token()
      8 else:
      9 token = input("Paste your Joplin API Token:")
---> 10 with open(".api_token.txt", "w") as f:
     11 f.write(token.rstrip())
     12 return token

PermissionError: [Errno 13] Permission denied: '.api_token.txt'
```

I opened the script in an interactive way in ipython and gave me **'/usr/lib/python3.9/site-packages/rest\_uploader' as the current path**. I don't if there is an expected directory which is or could be define so that rest\_uploader would find the .api\_token.txt. Should that be the directory were files are uploaded (this is what makes sense to me)?

I installed the script in archlinux with the following command:

```auto
pypi2pkgbuild.py git+https://github.com/kellerjustin/rest-uploader
```

which constructs automagically an archlinux package from github. Don't know if this could have modified something in the script.

The script was installed in /usr/lib/python3.9/site-packages/rest\_uploader/

```auto
 $ ls /usr/lib/python3.9/site-packages/rest_uploader. The following files were installed:

api_token.py cli.py __init__.py __pycache__ rest_uploader.py
```

---

<div class="post-metadata">

**Author:** ![kellerjustin](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kellerjustin/32/178_2.png) [@kellerjustin](https://discourse.joplinapp.org/u/kellerjustin)\
**Post date:** [14 June 2021 13:47 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/148 "2021-06-14T13:47:19Z")

</div>

I should refactor how that api token file is stored and put it in user space. You should be able to get around this by altering the permissions on the site-packages/rest\_uploader folder or running the script as root the first time to create the `.api_token.txt` file.  
Thanks for reporting!

---

<div class="post-metadata">

**Author:** ![harun27](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/harun27/32/9055_2.png) [@harun27](https://discourse.joplinapp.org/u/harun27)\
**Post date:** [19 July 2021 13:35 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/149 "2021-07-19T13:35:46Z")

</div>

Is it possible to process all images and pdfs that are already in my notes?

I also always get this error:  
`Too few characters. Skipping this page Error during processing.`  
Am I doing something wrong or are the images just bad?

---

<div class="post-metadata">

**Author:** ![kellerjustin](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kellerjustin/32/178_2.png) [@kellerjustin](https://discourse.joplinapp.org/u/kellerjustin)\
**Post date:** [19 July 2021 14:05 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/150 "2021-07-19T14:05:08Z")

</div>

rest\_uploader only handles the creation of new notes from files. You might want to check out [OCR Joplin Notes](https://github.com/plamola/ocr-joplin-notes) for what you're trying to do.  
Thanks!

---

<div class="post-metadata">

**Author:** ![laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@laurent](https://discourse.joplinapp.org/u/laurent)\
**Post date:** [25 July 2021 20:05 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/151 "2021-07-25T20:05:24Z")

</div>

If the Tesseract lib reliable enough in general? I've read that it's difficult to use, but it seems you managed to make it work well?

---

<div class="post-metadata">

**Author:** ![kellerjustin](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kellerjustin/32/178_2.png) [@kellerjustin](https://discourse.joplinapp.org/u/kellerjustin)\
**Post date:** [26 July 2021 14:49 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/152 "2021-07-26T14:49:13Z")

</div>

If it was terribly difficult to use, I wouldn't have been able to make it work 😄!  
I'll put it this way - the creator(s) of tesseract did the heavy lifting and made a pretty solid opensource OCR framework, and subsequently pytesseract made it easy to access from Python. I just had to hook into it. I've found it's much easier to deal with tesseract in Linux because package management makes it easy - in Windows, unless someone has released a better installer in the last six months or so, it's sort of a headache to install and involves setting environment variables.  
Thanks!

---

<div class="post-metadata">

**Author:** ![laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@laurent](https://discourse.joplinapp.org/u/laurent)\
**Post date:** [26 July 2021 15:04 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/153 "2021-07-26T15:04:51Z")

</div>

Thanks for the info, it seems indeed easier than I thought. Does it successfully OCR documents most of the time? Are there any issues when the documents are not in English?

---

<div class="post-metadata">

**Author:** ![kellerjustin](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kellerjustin/32/178_2.png) [@kellerjustin](https://discourse.joplinapp.org/u/kellerjustin)\
**Post date:** [26 July 2021 15:17 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/154 "2021-07-26T15:17:14Z")

</div>

It's been pretty solid. My handwriting is garbage so I don't expect it will work with any of my handwritten notes, but it seems to do well when processing a scanned text document. You pass tesseract a language parameter and other than the occasional testing, I only ever pass in `--eng` so I can't adequately answer your question as to how well it works with other languages. Hope that helps!

---

<div class="post-metadata">

**Author:** ![Chamo](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/chamo/32/11087_2.png) [@Chamo](https://discourse.joplinapp.org/u/Chamo)\
**Post date:** [5 December 2021 22:13 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/155 "2021-12-05T22:13:50Z")

</div>

I'm getting the following error message:  
Check Tesseract OCR Configuration  
UZN file C:\Users[username]\AppData\Local\Temp\tess\_tvjq976a loaded. Estimating resolution as 258 UZN file C:\Users[username]\AppData\Local\Temp\tess\_tvjq976a loaded. Warning. Invalid resolution 0 dpi. Using 70 instead. Too few characters. Skipping this page Error during processing.

Any ideas? From [Warning. Invalid resolution 0 dpi. Using 70 instead. · Issue #1702 · tesseract-ocr/tesseract · GitHub](https://github.com/tesseract-ocr/tesseract/issues/1702) it sounded like it might be an issue related to the metadata ("It means your image does not contain a resolution info in its metadata, so Tesseract warns you about this issue in the image and it tries to estimate the resolution by itself.") but I wasn't sure what to try to do to fix it.

---

<div class="post-metadata">

**Author:** ![kellerjustin](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kellerjustin/32/178_2.png) [@kellerjustin](https://discourse.joplinapp.org/u/kellerjustin)\
**Post date:** [6 December 2021 15:29 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/156 "2021-12-06T15:29:30Z")

</div>

Is this happening with all the images you try to upload, or just one particular file?

---

<div class="post-metadata">

**Author:** ![Chamo](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/chamo/32/11087_2.png) [@Chamo](https://discourse.joplinapp.org/u/Chamo)\
**Post date:** [6 December 2021 18:26 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/157 "2021-12-06T18:26:43Z")

</div>

I get that errors with all files I scan, unfortunately.

---

<div class="post-metadata">

**Author:** ![kellerjustin](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kellerjustin/32/178_2.png) [@kellerjustin](https://discourse.joplinapp.org/u/kellerjustin)\
**Post date:** [9 December 2021 00:33 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/158 "2021-12-09T00:33:07Z")

</div>

Hmm, it looks like it's trying to OCR the file before it's fully written. Are you monitoring a temp directory?

---

<div class="post-metadata">

**Author:** ![Chamo](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/chamo/32/11087_2.png) [@Chamo](https://discourse.joplinapp.org/u/Chamo)\
**Post date:** [10 December 2021 23:42 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/159 "2021-12-10T23:42:54Z")

</div>

Thank you @kellerjustin ! That likely is the issue. Unfortunately when I went to troubleshoot it, it started giving me the following error. Any thoughts on what I am doing wrong?

(base) C:\Users[username]\> rest\_uploader C:\Users[username].config\joplin-desktop\ImportingWithOCR  
Launching Application rest\_uploader.cli.main  
Endpoint: [http://127.0.0.1:41184](http://127.0.0.1:41184)  
Traceback (most recent call last):  
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in \_run\_module\_as\_main  
return \_run\_code(code, main\_globals, None,  
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run\_code  
exec(code, run\_globals)  
File "C:\ProgramData\Anaconda3\Scripts\rest\_uploader.exe\_main_.py", line 7, in   
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 1128, in **call**  
return self.main(\*args, \*\*kwargs)  
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 1053, in main  
rv = self.invoke(ctx)  
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 1395, in invoke  
return ctx.invoke(self.callback, \*\*ctx.params)  
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 754, in invoke  
return \_\_callback(\*args, \*\*kwargs)  
File "C:\ProgramData\Anaconda3\lib\site-packages\rest\_uploader\cli.py", line 126, in main  
notebook\_id = set\_notebook\_id(destination.strip())  
File "C:\ProgramData\Anaconda3\lib\site-packages\rest\_uploader\rest\_uploader.py", line 151, in set\_notebook\_id  
folders = res.json()["items"]  
KeyError: 'items'

---

<div class="post-metadata">

**Author:** ![kellerjustin](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kellerjustin/32/178_2.png) [@kellerjustin](https://discourse.joplinapp.org/u/kellerjustin)\
**Post date:** [12 December 2021 02:52 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/160 "2021-12-12T02:52:40Z")

</div>

Check to make sure you have the latest version of Joplin and rest\_uploader. There was a breaking change to the API several versions ago and this looks like what it might be.

---

<div class="post-metadata">

**Author:** ![Chamo](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/chamo/32/11087_2.png) [@Chamo](https://discourse.joplinapp.org/u/Chamo)\
**Post date:** [14 December 2021 14:48 UTC](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719/161 "2021-12-14T14:48:16Z")

</div>

OK, got it working. I think the issue was I had a user variable or system variable wrong. I followed these instructions [OCR in Joplin (How to) - #3 by myfta](https://discourse.joplinapp.org/t/ocr-in-joplin-how-to/16531/3) and the errors resolved. Then to my earlier issue, per your suggestion, I tried having the scanner save the file somewhere else, and then only once the file was completely saved, moved it to the monitored folder. Sure enough, the OCR worked! Thanks so much for all your help. Truly, if you hadn't built and maintained this script I wouldn't have used Joplin at all, having OCR was a firm requirement for me as I transitioned away from Evernote.

[Previous page](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719.md?page=7)

[Next page](https://discourse.joplinapp.org/t/file-uploader-and-ocr/719.md?page=9)
