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

No option to select screenshot format when copying to clipboard #36

Open
mfsoup opened this issue Mar 23, 2023 · 12 comments
Open

No option to select screenshot format when copying to clipboard #36

mfsoup opened this issue Mar 23, 2023 · 12 comments
Labels
help wanted Extra attention is needed

Comments

@mfsoup
Copy link

mfsoup commented Mar 23, 2023

The option to change screenshot format appears for me when saving images but disappears when copying to clipboard.

@joggee-fr
Copy link
Contributor

Hi @mfsoup. You're right, PNG format is forced by design when copying to clipboard. I don't know if it can work with JPEG format. When do you need clipboard image to be JPEG?

@mfsoup
Copy link
Author

mfsoup commented Mar 24, 2023

In my experience, the difference between JPEG and PNG on Youtube screenshots is nearly imperceptible while one is 1/5th the size. For example, these two images were taken through the extension: https://files.catbox.moe/ubq717.png https://files.catbox.moe/ua5rpw.jpeg

The difference in size can be noticeable when pasting to Discord or something on slow or unstable internet connections.

@joggee-fr
Copy link
Contributor

The clipboard.setImageData() API used in Firefox to copy the image in clipboard supports PNG and JPEG format.

@joggee-fr
Copy link
Contributor

@mfsoup, I have done some tests in a dedicated branch here. It seems to work.
However, in my macOS environment, whatever the selected image format, the saved data in the native clipboard seems to be a TIFF one. Let me know if you can test it and determine if it could be useful for others OS (Windows, Linux).

@himanshugoswamiii
Copy link

@mfsoup, I have done some tests in a dedicated branch here. It seems to work.

Hey, I tried this branch of yours on Linux. I'm able to select the JPEG format with copy to clipboard but the output screenshot is still of png type.

@joggee-fr
Copy link
Contributor

@himanshugoswamiii, thanks for your tests. Could you please describe a bit your environment and how you check the MIME type in clipboard please?

@himanshugoswamiii
Copy link

@joggee-fr , I'm currently running

OS: Endeavouros
Linux Kernel: 6.1.37-1-lts 
Firefox Version: 114.0.2 (64-bit)

I checked the mime type by pasting the image to my desktop. It showed the extension as png , the image size is around 700Kb as well, while when downloading the image extension is jpeg and size is around 90Kb

@joggee-fr
Copy link
Contributor

@himanshugoswamiii
Are you using a Wayland-based environment? If so, could you try the command wl-paste -l (available from wl-clipboard package) after copying the screenshot in expected JPEG format?

Maybe you could also add some traces using console.log() in background.js to check the type parameter passed to setImageData() and check it with Firefox devtools. To do so in Firefox, type about:debugging for the URL address. Then, go to "This Firefox" section. In the "Temporary add-ons" list, reload the patched branch and use "Inspect" button to load devtools.

Side note, my test branch were based on previous release and you MUST refresh the YouTube page for the configuration change to be applied.

Sorry, I don't have a full Linux environment right now to test it myself. Would be interesting to test it with Windows also as its clipboard is expected to support JPEG and PNG (Windows Clipboard Formats).

@gurumukhi, @mfsoup
What is your testing environment?

@gurumukhi
Copy link
Owner

I am using Mac.

@himanshugoswamiii
Copy link

Hey @joggee-fr, I think the problem is how copied image are being handled in my OS. So i noticed whenever i copy an image from web whether it's jpeg or png it gets copied as png only.

It happens from the web only
Btw i have a workaround for this. KDE Plasma allows me to select Mime type when pasting

I will inform if i found the issue. If someone is using windows they can check if this behavior occurs there as well

This post is also telling the same thing with chrome
https://forum.obsidian.md/t/pasted-images-convert-to-jpg-instead-of-png/11100/4

@mfsoup
Copy link
Author

mfsoup commented Aug 3, 2023

@mfsoup, I have done some tests in a dedicated branch here. It seems to work. However, in my macOS environment, whatever the selected image format, the saved data in the native clipboard seems to be a TIFF one. Let me know if you can test it and determine if it could be useful for others OS (Windows, Linux).

Sorry for the late reply but the build still copies as png for me as well.
Latest Windows 10 running Firefox 116.0

@joggee-fr
Copy link
Contributor

This issue seems very OS-dependent and I feel like there is not a reliable solution to force the MIME type in the clipboard.

@gurumukhi gurumukhi added the help wanted Extra attention is needed label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants