Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent OCR on Windows OneNote copy text #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion manga_ocr/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from PIL import Image
from PIL import UnidentifiedImageError
from loguru import logger
from PIL.BmpImagePlugin import DibImageFile

from manga_ocr import MangaOcr

Expand Down Expand Up @@ -97,7 +98,17 @@ def run(read_from='clipboard',
else:
logger.warning('Error while reading from clipboard ({})'.format(error))
else:
if isinstance(img, Image.Image) and not are_images_identical(img, old_img):
if (
isinstance(img, DibImageFile)
and sys.platform == "win32"
and not are_images_identical(img, old_img)
):
# Windows OneNote copies images as DibImageFile ignore by default
# Windows Screen Snip copies images as PngImageFile
pass
elif isinstance(img, Image.Image) and not are_images_identical(
img, old_img
):
process_and_write_results(mocr, img, write_to)

time.sleep(delay_secs)
Expand Down