Save me from the Sonoma pain

This commit is contained in:
AuroraWright
2024-02-12 00:52:16 -05:00
parent b0a68b643c
commit 3aa1be2d4e

View File

@@ -465,7 +465,7 @@ def run(read_from=None,
img = None img = None
if sys.platform == 'darwin': if sys.platform == 'darwin':
from AppKit import NSPasteboard, NSPasteboardTypeTIFF, NSPasteboardTypeString from AppKit import NSPasteboard, NSPasteboardTypeTIFF, NSPasteboardTypeString, NSBitmapImageRep, NSBitmapImageFileTypeBMP
pasteboard = NSPasteboard.generalPasteboard() pasteboard = NSPasteboard.generalPasteboard()
count = pasteboard.changeCount() count = pasteboard.changeCount()
mac_clipboard_polling = True mac_clipboard_polling = True
@@ -600,7 +600,10 @@ def run(read_from=None,
if NSPasteboardTypeString in pasteboard.types(): if NSPasteboardTypeString in pasteboard.types():
clipboard_text = pasteboard.stringForType_(NSPasteboardTypeString) clipboard_text = pasteboard.stringForType_(NSPasteboardTypeString)
if ignore_flag or clipboard_text != '*ocr_ignore*': 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 process_clipboard = True
else: else:
if not paused: if not paused: