CrossCopy / tauri-plugin-clipboard

A Tauri clipboard plugin with text, files, html, RTF, and image support. Clipboard content update monitoring is also supported.
https://crosscopy.github.io/tauri-plugin-clipboard/
MIT License
122 stars 6 forks source link

Copying image using Ctrl+C renders transparent image depending on the image editor #6

Closed filipemeneses closed 2 months ago

filipemeneses commented 1 year ago

I think this is just an issue with legacy programs. Using the README example, listenImageContent generates a transparent image when selecting and copying from MS Paint or Photoshop CS6 13.0. Pasting this same clipboard on a browser, works fine (i.e. this Github form)

Tested with Krita 5.1.5 and worked fine.

import { emit, listen} from "@tauri-apps/api/event";
import {
    IMAGE_CHANGED,
    listenImage,
} from "tauri-plugin-clipboard-api";

let listenTextContent = "";
let listenImageContent = "";
let tauriTextUnlisten;
let tauriImageUnlisten;
let textUnlisten: () => void;
let imageUnlisten: () => void;

export async function startListening() {
    tauriImageUnlisten = await listen(IMAGE_CHANGED, (event) => {
        console.log(event);
        listenImageContent = event.payload.value;
    });
    imageUnlisten = listenImage();
}

function stopListening() {
    imageUnlisten();
    tauriImageUnlisten();
}

onMount(() => {
    startListening();
});

onDestroy(() => {
    stopListening();
});

Base64 from selecting an area and pressing Ctrl + C:

iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAHUlEQVR4AQESAO3/AP/yAAD/8gAAAP/yAAD/8gAATdQHxbCRuT4AAAAASUVORK5CYII

image

Base64 from using Windows screenshot by pressing Windows + Shift + S:

iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAw0lEQVR4Ae3gAZAkSZIkSRKLqpm7R0REZmZmVlVVVVV3d3d3d/fMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMdHd3d3dXV1VVVVVmZkZGRIS7m5kKz0xmV3d1d3dPz8zMzMxMYvUe5nkBUHn+AKg8fwBUnj8AKs8fAJXnDwAZkAEZ78lcAcA/Asq4CPp4sUVpAAAAAElFTkSuQmCC

image

HuakunShen commented 1 year ago

I will look into this. I guess the image saved to clipboard have different format.

Thanks.

HuakunShen commented 2 months ago

Can you try again? @filipemeneses The plugin has been update, I don't think this issue exists any more.