-
Notifications
You must be signed in to change notification settings - Fork 456
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
Images are stored as text when copied from web browsers #2084
Comments
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:
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.) |
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: |
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" |
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: #1591 (comment) |
The problem still remains |
@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 |
@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. |
@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. |
This issue is not related to:
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. Note: Using Vivaldi's screenshot feature with »Copy to Clipboard« option works as intended (even with custom automatic commands). System Infomation: Desktop: ¹ Don't take this one for granted. 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-Browsers-Images-issue-Video_2023-10-27_072615.webm |
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:
Not sure why you see Can you check if in your CopyQ installation you have BTW, I think it should at least be possible to transform the [Command]
Automatic=true
Command="
copyq:
setData('image/png', input())"
Icon=\xf1c5
Input="application/x-qt-windows-mime;value=\"PNG\""
Name=Store Windows PNG |
But what happened? It used to work before, definitely in 3.x versions. Unfortunately, the In the
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. Topics, that led to the aforementioned link: |
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.
The console output on Windows does not work for GUI apps unfortunately (#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:
[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 |
CopyQ-Image-copy-in-Firefox-Video_2023-11-03_001848.webm |
Windows & WebP if OS is Windows , the image format is WebP. CopyQ can not show this image. |
Dear hluk, I'm using CopyQ about two weeks now and I like it very much, but now I ran into the "image-gate" and found out, that this problem exists since 2022. Do you think that there will be a solution for this, because a clipboard manager that doesn't like images, is not exactly what I was looking for? All I can contribute is:
If I can somehow assist you, just let me know. Markus
|
@MarGeb1 What is the clipboard content and specifically value of text/html? (See the formats in File - Show Clipboard Content dialog.)
CopyQ usually works well with images. If you know about a way to get an image (without doing network requests) from a system clipboard without any known image formats, please let me know. |
That's the output for the Mint desktop picture on https://linuxmint.com/edition.php?id=316:
|
Not sure why it does not work for you. The regular expressing Is there any error in logs? Can you try to remove the command and add it again? Do you use the latest CopyQ version? Interestingly, there is also |
That's the command I used, is it correct? `[Command]
Icon=\xf1c5 I re-added it again but with no success. During my tests yesterday i had several CopyQ Warning [2024-12-12 16:35:19.430] : [qt.qpa.mime] QtWarning: Retrying to obtain clipboard. warnings, but not today. |
Here the complete warnings, sorry:
I'm using v9.1.0 |
Can you try the following command to troubleshoot? It would show a popup with details if it cannot fetch an image or if it succeeds. [Command]
Automatic=true
Command="
copyq:
const regex = /<img [^>]*src=\"([^\"]+)\"/i;
if ( dataFormats().indexOf(mimeHtml) == -1 ) {
popup('No HTML');
abort();
}
if ( dataFormats().indexOf(mimeText) != -1 ) {
popup('Contains text');
abort();
}
if ( dataFormats().indexOf('image/png') != -1 ) {
popup('Contains image');
abort();
}
const html = str(data(mimeHtml));
const m = html.match(regex);
if (!m) {
popup('No image available', html);
abort();
}
const url = decodeURIComponent(m[1]);
var response = networkGet(url);
if (response.status != 200) {
popup('Failed to fetch the image', `${url}\\nstatus code: ${response.status}`);
abort();
}
popup('Adding an image', url);
setData('image/png', response.data);"
Icon=
Name=Fetch Image from HTML |
Hmm, that is strange. According to the previous clipboard content screenshot, there should be no Can you try to update the command to the following? Specifically, it replaces [Command]
Automatic=true
Command="
copyq:
const regex = /<img [^>]*src=\"([^\"]+)\"/i;
if ( dataFormats().indexOf(mimeHtml) == -1 ) {
popup('No HTML');
abort();
}
if ( str(data(mimeText)).trim() != '' ) {
popup('Contains text');
abort();
}
if ( dataFormats().indexOf('image/png') != -1 ) {
popup('Contains image');
abort();
}
const html = str(data(mimeHtml));
const m = html.match(regex);
if (!m) {
popup('No image available', html);
abort();
}
const url = decodeURIComponent(m[1]);
var response = networkGet(url);
if (response.status != 200) {
popup('Failed to fetch the image', `${url}\\nstatus code: ${response.status}`);
abort();
}
popup('Adding an image', url);
setData('image/png', response.data);"
Icon=
Name=Fetch Image from HTML |
Can you please check what text ( |
text/plain is file:///C:/Users/Markus/AppData/Local/Temp/4402013300970224452.jpg |
Interesting, so I guess you could also use that file as image. Anyway, here is the fixed version which fetches the remote image: [Command]
Automatic=true
Command="
copyq:
const regex = /<img [^>]*src=\"([^\"]+)\"/i;
if ( dataFormats().indexOf(mimeHtml) == -1 ) {
abort();
}
const text = str(data(mimeText)).trim();
if ( text != '' && !text.startsWith('file://') ) {
abort();
}
if ( dataFormats().indexOf('image/png') != -1 ) {
abort();
}
const html = str(data(mimeHtml));
const m = html.match(regex);
if (!m) {
abort();
}
const url = decodeURIComponent(m[1]);
serverLog('Fetching image: ' + url);
const response = networkGet(url);
if (response.status != 200) {
popup('Failed to fetch the image', `${url}\\nstatus code: ${response.status}`);
abort();
}
setData('image/png', response.data);"
Icon=
Name=Fetch Image from HTML |
Oops, sorry, the second I've updated the command in my previous comment. |
Oh, for Facebook, I think the command would need to go through some HTTP redirects or even log into an account. It would be much better to use the image path if it is in the |
Found a solution that doesn't require fetching: global.hasImageFormat = function (formats) {
for (const format of formats.values()) {
if (format.startsWith('image/'))
return true;
}
return false;
};
const imageMime = 'image/png';
const mimeText = 'text/plain';
const onClipboardChanged_ = onClipboardChanged;
onClipboardChanged = function () {
if (isClipboard()) {
const formats = dataFormats();
// Fix for Chrome image issue
const imageData = clipboard(imageMime);
if (imageData.length > 0 || hasImageFormat(formats)) {
removeData(mimeText)
setData(imageMime, imageData);
}
}
onClipboardChanged_();
} |
Hi, dear.
My problem is exactly the same as mentioned in the following Post:
#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
The text was updated successfully, but these errors were encountered: