GithubHelp home page GithubHelp logo

ianzhao05 / textshot Goto Github PK

View Code? Open in Web Editor NEW
1.7K 1.7K 259.0 63 KB

Python tool for grabbing text via screenshot

License: MIT License

AutoHotkey 3.32% Python 96.68%
ocr ocr-recognition python python-3 python-script python3 screenshot script tesseract tesseract-ocr

textshot's People

Contributors

0xflotus avatar 1ace avatar alinuxperson avatar br3w0r avatar dependabot[bot] avatar ianzhao05 avatar jonahsol avatar krithikvaidya avatar ravipabari avatar snoopydevelops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

textshot's Issues

Doesn't support MacBook Fullscreen

This tool could only take a shot on its current desktop. However, MacBook has a multi-desktop feature, and you can't ask this tool to take a shot on the desktop where the terminal is opened. Hope the author can support multi-desktop screenshots.

macOS Big Sur opens new screen

I just downloaded text shot on my Mac and installed all the dependencies but have been experiencing this weird behavior where as soon as I run it it will open a new screen to the right with no open apps and would only allow me to screenshot there. Did anyone else encounter this or have a fix?

2021-02-27 19:08:54.739 Python[952:13732] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/ld/wjmpqdpj1pq2j4j_svh1j8740000gn/T/org.python.python.savedState

Screen Recording

Segmentation fault, (core dumped)

I tried to run textshot on my fedora Linux machine and I got a segmentation fault error:
Traceback (most recent call last): File "/home/maerqin/PycharmProjects/Screenshot_To_Text/venv/lib/python3.12/site-packages/textshot/textshot.py", line 11, in <module> from .logger import log_copied, log_ocr_failure ImportError: attempted relative import with no known parent package [1] 82030 segmentation fault (core dumped) python textshot.py -h

ERROR: Unable to read text from image, did not copy

On recent Arch linux with i3wm window manager I often get ERROR: Unable to read text from image, did not copy.

I have :

  • python-pyqt5 : 5.15.8
  • python-pyqt5-sip: 12.11.1
  • python-pillow: 9.4.0
  • python-pytesseract: 0.3.10

screenshot "E:\>cd github" output -->"INFO: Copied "AR" to the clipboard"

screenshot "E:>cd github" output -->"INFO: Copied "AR" to the clipboard"

the command line test info:

E:\github>cd..

E:>cd github

E:\github>cd textshot

E:\github\textshot>python textshot.py
**INFO: Copied "E:\github>cd. .
AR

E:\github>cd textshot" to the clipboard**

E:\github\textshot>python textshot.py chi_sim
**INFO: Copied "ET
E:N>cd github

E:Ngithub>cd textshot" to the clipboard**

E:\github\textshot>

Doesn't work in multi-monitor setup

I have two screens (let's name them Main and Side). When I open type textshot in a terminal in Side, the Main monitor starts mirroring Side monitor's content.

So, to copy text from Main, I have to open the terminal in Main. This is not a good experience

License

Please add a license file.

Consider adding pyproject.toml for package installation

Here is a pyproject.toml example

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "textshot"
version = "0.0.1"
authors = [
  { name="Ian ianzhao05", email="[email protected]" },
]
description = "Python tool for grabbing text via screenshot"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
]
dynamic = ["dependencies"]

[project.urls]
"Homepage" = "https://github.com/ianzhao05/textshot"
"Bug Tracker" = "https://github.com/ianzhao05/textshot/issues/"

[project.scripts]
textshot = "textshot.textshot:main"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools.packages.find]
where = ["textshot"]

It may need some tweaking and modifying the project to relocate python files in textshot and changing the way import is done by using something like from .ocr import … for example.

It would be helpful to make a working package for linux distributions.

You then build and install the package with:

python3 -m build --wheel
python -m installer dist/*.whl

Error

ERROR: An error occurred when trying to process the image: (1, "Tesseract Open Source OCR Engine v3.05.00dev with Leptonica read_params_file: Can't open txt Warning in pixReadMemPng: work-around: writing to a temp file libpng warning: Application built with libpng-1.4.3 but running with 1.5.14 Error in pixReadStreamPng: png_ptr not made Error in pixReadMemPng: pix not read Error in pixReadMem: png: no pix returned Error during processing.")

Failed when have multiple monitors

image

Once I unplugged from external monitors it worked well. The problem is raised from line 29 in textshot.py,
self.screen = QtWidgets.QApplication.screenAt(QtGui.QCursor.pos()).grabWindow(0)

My system is MacOS 10.15.3, with python 3.6.9. Thank you.

[Feature suggestion] Add an auto magnification

Sometimes the target is too small on the screen and I can't capture it accurately. Maybe it is a good idea to add a magnified image based on what is around the cursor when users are capturing the screen.

could not work on MacOS

on Mac get

INFO: Unable to read text from image, did not copy

seems pyperclip do not work properly on MacOS.

textshot on macOS Big Sur

Hi,

On macOS 11.1, invoking python textshot.py throws a Qt GUI error:

QPixmap::fromImage: QPixmap cannot be created without a QGuiApplication
QPixmap: Must construct a QGuiApplication before a QPixmap

Any suggestions? This worked fine before updating to Big Sur. Thank you!

EDIT: This has been tried with a virtual environment.

Added your package to arch linux aur

Just a friendly heads up that I've added your package to the archlinux aur and it will keep itself updated based on the latest git commits to the github repo.
https://aur.archlinux.org/packages/textshot-git

So for arch users it's as easy as installing textshot-git with their favourite aur helper.
yay -S textshot-git

Also is there a way to make textshot pause the desktop (animations like the gif on this page)?
Currently it keeps on animating while in box select mode.

Thanks for the great tool!

Tesseract Process Timeout

Appears to not work on more than 5 words at a time, presents with error

"TextShot"
"An error occurred when trying to process the image: Tesseract process timeout"

Size limitation for text, and sometimes prior OCR conversion in clipboard is not replaced with new OCR conversion

Hi
I think this is a really cool idea to make OCR simple to do and allows for correcting OCR mistakes very easily.
I am on a Windows machine and I find that I need to OCR a large text image in parts because it doesn't handle
a lot of text well. Is there a recommended maximum amount of text that should be selected for conversion?
But even doing OCR in parts, some areas appear to be captured and the "spinning wheel" indicates that
a conversion is being done. But when pasting the text that is in the clipboard to notepad++, it is the text from a prior conversion.
If there is an error in the conversion process, I can't find where it is displayed. Can you please give me some pointers
on getting around these issues?
Thanks!

Selection not from upper left corner

When I make a selection starting not from the upper left corner, but from any other corner, instead of the text in selection it returns some long random text, which seems to be the text from all screen.

To reproduce, make a selection of some text from, for example, lower right corner to upper left corner.

2022-02-09.11.12.21.mp4

Does not pause desktop while snipping

The screen overlay does not pause the desktop while snipping. For example, videos and GIFs continue to play in the background. This is inconsistent with Windows's screenshot tools, Snipping Tool and the newer Snip & Sketch.

Raised by @rigred in #12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.