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

Bug: Cannot read clipboard image on MacOS for screenshots taken by certain apps #19

Closed
HuakunShen opened this issue Apr 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@HuakunShen
Copy link
Contributor

HuakunShen commented Apr 12, 2024

The problem | 问题描述

Issue first mentioned in CrossCopy/tauri-plugin-clipboard#21 by @Tester-957

Screenshots taken with Feishu/Lark can neither be detected nor read by clipboard-rs, while regular screenshots and screenshots taken by other apps like WeChat could be detected.

By running the sample code we can see that ctx.get_image() doesn't return Err, but the resulting image has a size of (0, 0)

Release version | 版本

0.1.5

Operating system | 操作系统

MacOS

Logs | 日志

No response

@HuakunShen
Copy link
Contributor Author

HuakunShen commented Apr 12, 2024

Bug located

Here is the available formats for a regular screenshot: ["public.png", "Apple PNG pasteboard type", "public.tiff", "NeXT TIFF v4.0 pasteboard type"]

Here is the available formats for a Feishu screenshot ["public.tiff", "NeXT TIFF v4.0 pasteboard type"]

Screenshot taken with Feishu somehow doesn't support PNG format, and only PNG is considered in the code

let ns_data = self.clipboard.dataForType(NSPasteboardTypePNG);

Solution

clipboard.dataForType(NSPasteboardTypeTIFF) will return screenshots from Feishu.
TIFF is supported by both regular screenshot and Feishu screenshot (verified), so you could simply replace NSPasteboardTypePNG with NSPasteboardTypeTIFF
However, it might be prudent to handle both TIFF and PNG formats for has() and get_image(), ensuring compatibility across different scenarios. Supporting both formats is a safer approach.

@HuakunShen
Copy link
Contributor Author

HuakunShen commented Apr 12, 2024

PR opened here by @ChurchTao #16

Fixed by adding a check on the value of png and tiff returned. If there is no data, Err is returned.

@ChurchTao
Copy link
Owner

next version will be ok~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants