youtube-screenshot icon indicating copy to clipboard operation
youtube-screenshot copied to clipboard

No option to select screenshot format when copying to clipboard

Open mfsoup opened this issue 1 year ago • 12 comments

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

mfsoup avatar Mar 23 '23 12:03 mfsoup

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?

joggee-fr avatar Mar 23 '23 13:03 joggee-fr

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.

mfsoup avatar Mar 24 '23 07:03 mfsoup

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

joggee-fr avatar Jun 21 '23 08:06 joggee-fr

@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).

joggee-fr avatar Jun 21 '23 08:06 joggee-fr

@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.

himanshugoswamiii avatar Jul 03 '23 08:07 himanshugoswamiii

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

joggee-fr avatar Jul 03 '23 16:07 joggee-fr

@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

himanshugoswamiii avatar Jul 03 '23 19:07 himanshugoswamiii

@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?

joggee-fr avatar Jul 04 '23 13:07 joggee-fr

I am using Mac.

gurumukhi avatar Jul 04 '23 14:07 gurumukhi

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

himanshugoswamiii avatar Jul 04 '23 19:07 himanshugoswamiii

@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

mfsoup avatar Aug 03 '23 04:08 mfsoup

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

joggee-fr avatar Aug 10 '23 18:08 joggee-fr