-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix the known issue of saving JPEG to clipboard on macOS #3724
base: master
Are you sure you want to change the base?
Conversation
Hi @mmahmoudian |
@Ariandr thanks for the PR. I'm not quite sold on the idea of using Apple Script to handle this, but perhaps that stems from my lack of familiarity with osascript. Is this a common practice inApple world? I would rather wait for a dev that knows Apple ecosystem more to decide on this. Regardless of this, the code looks clean to me. Thanks again for your valuable contribution and the time you have invested in this. I hope this get merged fast if there is mo objections shit the osascript. |
@mmahmoudian It is also built into the OS, so it does not require any special dependencies or installations on the user machine. Actually, it's a preferred way, because in case the user needs to provide the permission to write to the clipboard, macOS will ask it, because it's Apple's supported tool, while other libraries/ways might not do it. Apple's Automator Mac app is built on using |
Also, while looking for this solution, I've tried some other ways. They (e.g. Qt Clipboard Management) just cannot achieve the same result of saving the compressed JPEG to clipboard. The only alternative that potentially can work is adding Objective-C runtime and Objective-C files to use |
In any case, until a better approach is found (we can leave a comment to investigate alternatives later or investigation welcome), I think it's good enough. The main thing is that it's reliable and doesn't break anything. By default, all macOS users will have it disabled anyway, since the PNG is the default way of saving to clipboard. I'm using the app today extensively, the fix works like a charm. |
Another issue was that my memory usage of Flameshot used to grow fast. In a day of extensive use, it could get to 1-2 GB in memory for whatever reason, while I was taking screenshots and copied them to clipboard as PNGs. So I always killed the app and relaunched it. With this fix, the positive side effect is that the memory footprint stays the same under 100 MB (actually around 20 MB), apparently it's more efficient than saving PNG to clipboard via |
Hi @mmahmoudian So I think macOS users will definitely benefit from this PR. |
I fixed the known issue while setting
useJpgForClipboard=true
on macOS.I wrote specific macOS function for this case and re-introduced this setting to GUI.
The code is tested and I run the app on my Mac.
The initial issue is here with more context: #3722
For the quick test, you can use the built app with the fix: #3722 (comment)
Results:
The same screenshot in a
.png
is 7.6 MB in size, in a.jpeg
it's a 850 KB with 90 compression quality.