From 3aa1be2d4ec8e51ce94a0f1e65f0b03e9e3e48b3 Mon Sep 17 00:00:00 2001 From: AuroraWright Date: Mon, 12 Feb 2024 00:52:16 -0500 Subject: [PATCH] Save me from the Sonoma pain --- owocr/run.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/owocr/run.py b/owocr/run.py index 9827d5b..f0e0db7 100644 --- a/owocr/run.py +++ b/owocr/run.py @@ -465,7 +465,7 @@ def run(read_from=None, img = None if sys.platform == 'darwin': - from AppKit import NSPasteboard, NSPasteboardTypeTIFF, NSPasteboardTypeString + from AppKit import NSPasteboard, NSPasteboardTypeTIFF, NSPasteboardTypeString, NSBitmapImageRep, NSBitmapImageFileTypeBMP pasteboard = NSPasteboard.generalPasteboard() count = pasteboard.changeCount() mac_clipboard_polling = True @@ -600,7 +600,10 @@ def run(read_from=None, if NSPasteboardTypeString in pasteboard.types(): clipboard_text = pasteboard.stringForType_(NSPasteboardTypeString) if ignore_flag or clipboard_text != '*ocr_ignore*': - img = Image.open(io.BytesIO(pasteboard.dataForType_(NSPasteboardTypeTIFF))) + img_tiff = pasteboard.dataForType_(NSPasteboardTypeTIFF) + img_representation = NSBitmapImageRep.alloc().initWithData_(img_tiff) + img = img_representation.representationUsingType_properties_(NSBitmapImageFileTypeBMP, None) + img = Image.open(io.BytesIO(img)) process_clipboard = True else: if not paused: