CopyQ
CopyQ copied to clipboard
Images are stored as text when copied from web browsers
Hi, dear. My problem is exactly the same as mentioned in the following Post:
https://github.com/hluk/CopyQ/issues/1100
but the code that was given at it does not work for me. I don't know if it is a bug in new version of CopyQ or an incompatibility between CopyQ and the new version of my browser!?
When I press F4, the following formats are listed for my images:
text/plain text/html
Thanks for any help Best Regards
Can you be more specific? Do you mean images are not shown in CopyQ?
Can you check installed plugins in Items tab in Preferences dialog? It should list "Images".
Yes, exactly. Images (albeit just Images that I have copied them with Firefox or Chrome's "Copy Image" option) have not any thumbnail and I can not paste them as an image in other programs (e.g. PhotoShop, PaintShop, ...). Other images (i.e. Images that I have copied outside the browser) have not any problem and are copied by CopyQ correctly.
Yes I have "Images" under CopyQ -> Preferences -> Items.
P.S.: after using the following code:
copyq:
var height = 200
var filePath = str(input())
setData(mimeHtml,
'<img height="' + height + '" src="' + filePath + '" />'
)
my copied image thumbnails were backed and I can see them in CopyQ. But all of them are fake and no one of the images can be pasted in graphic programs.
Can you check clipboard if there are really any image formats after you copy them from web browser? (You can check current clipboard format with Ctrl+Shift+C from CopyQ.)
Can you check clipboard if there are really any image formats after you copy them from web browser? (You can check current clipboard format with Ctrl+Shift+C from CopyQ.)
Well, I'm sure there is an image formats in clipboard after copying them from web browser, because I can paste the last copied image from clipboard to any graphic program without any problem, however, CopyQ can not show the last copied image too!
BTW, I used Ctrl+Shift+C from CopyQ and there is a snapshot for you:
Well, I'm sure there is an image formats in clipboard after copying them from web browser, because I can paste the last copied image from clipboard to any graphic program without any problem, however, CopyQ can not show the last copied image too!
It does not look like there is any image data CopyQ can use in the clipboard. Some applications can get the remote image from the HTML formatted data (or maybe from the uri-list). But CopyQ by default does not make any network requests.
BTW, what is the web browser? I tested it in Firefox 104.0.1 on Fedora 36 and it provides some standard image data in clipboard so CopyQ saves them as images correctly.
It does not look like there is any image data CopyQ can use in the clipboard. Some applications can get the remote image from the HTML formatted data (or maybe from the uri-list). But CopyQ by default does not make any network requests.
BTW, what is the web browser? I tested it in Firefox 104.0.1 on Fedora 36 and it provides some standard image data in clipboard so CopyQ saves them as images correctly.
I tested by FireFox_v91.13.0esr_64-bit, Chrome_v105.0.5195.102 (Official Build 64-bit) and Edge_v105.0.1343.33 (Official build 64-bit). My main Browser is FireFox. For example at the following link, no one of pictures can be copied by "Copy Image"
https://www.jaaar.com/kiosk#rows/all/
I tested it in Firefox 104.0.1 on Fedora 36 and it provides some standard image data in clipboard so CopyQ saves them as images correctly.
After your message, I thought maybe that is a problem with ESR version of Firefox, so I tested with the normal version (Firefox_v104.0.1). But the problem was not solved. Everything was exactly the same as previous.
P.S.: After copying the photo by "Copy Image", a file will be created from it in my Windows Temp folder. Is it possible to re-upload that file as a photo to CopyQ through a JS code for problem workaround?
I think the solution would be similar to this: https://github.com/hluk/CopyQ/issues/1591#issuecomment-983280874
I'm using Brave browser on Linux, this is not only Windows now, imo. Here's is my reproduction step:
- right click image and "Copy image"
- see the content of clipboard using Ctrl+Shift+C
- the clipboard really showing the image
- see the content of CopyQ of that image, no image
@latipun7 That looks like a different issue. Did you enable "Images" plugin in Items configuration tab in Preferences? Otherwise CopyQ will not store images. It is enabled by default unless plugins are not installed at all (sometimes there is a separate package copyq-plugins
).
@hluk , yes, it is enabled. I'm able to see image copied to clipboard from flameshot for example. But not from browser "Copy Image". Did I miss some requirement or something? I just installed Linux and copyq (fresh install).
When I click "Copy Image" in browser, my clipboard really did has image, so I can paste here in github comment for example. But if I copy from copyQ, when I paste here, it only the link/plain text.
Here's my clipboard in CopyQ looks like:
@latipun7 The image is probably not stored because of an automatic command. But that is a different issue, because you have a usable image format in clipboard. In the original issues there seems to be no image data in the system clipboard.
oh, what should I do, @hluk ? Should I open new issue? Because I don't know what is blocking this image to be saved in CopyQ. I only has 1 custom auto command.
@latipun7 Please open a new issue.
@hluk The image is probably not stored because of an automatic command. But that is a different issue, because you have a usable image format in clipboard. In the original issues there seems to be no image data in the system clipboard.
This issue is not related to:
- Any custom settings or commands (config).
- Specific operating sytems.
But it is definitely related to Chromium based WebBrowsers! (See Palemoon Screenshot below for reference.)
I've had this issue for quite a while now: in Chromium, Brave¹, Vivaldi, Ungoogled Chromium, and some more.
I added .bak
to CopyQ's folders to start it freshly² and make some samples that can be seen below.
Note: Using Vivaldi's screenshot feature with »Copy to Clipboard« option works as intended (even with custom automatic commands).
System Infomation:
Desktop: GNOME 44
Windowing System: Wayland
OS: Manjaro Linux (rolling release)
Kernel: 6.1.31-2-MANJARO #1 SMP PREEMPT_DYNAMIC
Laptop: Dell Latitude E5470
¹ Don't take this one for granted.
² To ~/.local/share/copyq
and ~/.config/copyq
Copied Image from Vivaldi:
Same Image copied from Palemoon:
Image copied from the Site in This Comment using Vivaldi:
i'm experiencing the same thing. preview of screenshot images show up in copyq items just fine but the moment I "copy image" from chrome on windows. I get a small white box instead.
I used copyq-v3.9.3 for a long time without this sort of issue but I just recently noticed(using v6.3.2) that this white square box appears instead if the image. the only time i use to see that white square box on version 3.9.3 is when I did 'copy image' on a really high resolution image.
the tabs I have with images stored in clipboard saved with 3.9.3 still appear normally in 6.3.2
does anyone know which of the most recent version of copyq where this bug isn't present?
Have the same issue:(
Version, OS and Environment
- CopyQ 7.1.0
- OS: Microsoft Windows [Version 10.0.19045.2673] 64bit
- Browser: Firefox 119.0 64bit
- Browser: Chrome 118.0.5993.90 (Official Build) (64-bit)
- Browser: Edge 118.0.2088.69 (Official build) (64-bit)
I don't think I can do anything about this since the clipboard (and basically Qt framework that CopyQ uses) does not seem to provide the image data.
For me on Linux in Firefox 118.0.2, right clicking on an image on a web page and selecting Copy Image, works well. There is a variety of image formats in the clipboard:
❯ copyq clipboard \?
text/html
text/_moz_htmlinfo
text/_moz_htmlcontext
image/png
image/jpeg
image/bmp
image/x-bmp
image/x-MS-bmp
image/x-icon
image/x-ico
image/x-win-bitmap
image/vnd.microsoft.icon
application/ico
image/ico
image/icon
text/ico
image/tiff
image/webp
audio/x-riff
Not sure why you see application/x-qt-image
or even application/x-qt-windows-mime;value="PNG"
but no usable image format.
Can you check if in your CopyQ installation you have imageformats
folder containing some DLL files?
BTW, I think it should at least be possible to transform the application/x-qt-windows-mime;value="PNG"
when available to image/png
automatically with the following command (here is how to add the command to CopyQ):
[Command]
Automatic=true
Command="
copyq:
setData('image/png', input())"
Icon=\xf1c5
Input="application/x-qt-windows-mime;value=\"PNG\""
Name=Store Windows PNG
I don't think I can do anything about this since the clipboard (and basically Qt framework that CopyQ uses) does not seem to provide the image data.
But what happened? It used to work before, definitely in 3.x versions. Moreover, this bug only applies to copying in browsers, any of them. Copying from any other apps, the images are saved as images. And also this bug with the inability to copy any images larger than a certain size. https://github.com/hluk/CopyQ/issues/2523 It seems that it's all interconnected.
Unfortunately, the copyq clipboard \?
command does not work the same way in Windows as it does in Linux.
In the imageformats
folder, I have the following files:
qsvg.dll
qwebp.dll
qwbmp.dll
qtiff.dll
qtga.dll
qicns.dll
qjpeg.dll
qico.dll
qgif.dll
BTW, I think it should at least be possible to transform the
application/x-qt-windows-mime;value="PNG"
when available toimage/png
automatically with the following command (here is how to add the command to CopyQ):[Command] Automatic=true Command=" copyq: setData('image/png', input())" Icon=\xf1c5 Input="application/x-qt-windows-mime;value=\"PNG\"" Name=Store Windows PNG
Oh, thank you very much! And this already works in Edge and Chrome! But Firefox is overboard :(((((
Found something, maybe it will somehow give you some idea on how to solve the pressing problem. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/clipboard/setImageData
Topics, that led to the aforementioned link: https://github.com/Xpra-org/xpra-html5/issues/71 https://github.com/w3c/clipboard-apis/issues/44
But what happened? It used to work before, definitely in 3.x versions.
Old versions of CopyQ rendered HTML items with images (and any other remote content). New versions (since v4.0.0) uses simpler rendering and does not make any network requests so the images show up as a dummy icon.
Unfortunately, the
copyq clipboard \?
command does not work the same way in Windows as it does in Linux.
The console output on Windows does not work for GUI apps unfortunately (https://github.com/hluk/CopyQ/issues/349).
You can use the Action dialog (F5 shortcut) in CopyQ instead with "Store standard output" set to "text/plain" to store the command output to new item.
Below is a command that tries to extract the image URL from HTML and fetch the image.
A couple of downsides:
- it uses a regular expression to find the image URL in HTML which may not work in some cases
- it always stores the image with "image/png" format, this works in CopyQ even if the image format is JPEG but may fail when pasting to some apps (in some cases it would be possible to guess the format from URL itself but not always)
- it does not work with HTTP redirects
[Command]
Automatic=true
Command="
copyq:
const regex = /<img [^>]*src=\"([^\"]+)\"/i
if ( dataFormats().indexOf(mimeHtml) == -1
|| dataFormats().indexOf(mimeText) != -1
|| dataFormats().indexOf('image/png') != -1)
{
abort();
}
const html = str(data(mimeHtml))
const m = html.match(regex)
if (!m) {
abort();
}
const url = decodeURIComponent(m[1]);
var response = networkGet(url)
if (response.status != 200) {
abort();
}
setData('image/png', response.data)"
Icon=\xf1c5
Name=Fetch Image from HTML
Windows & WebP
if OS is Windows , the image format is WebP.
CopyQ can not show this image.