Skip to content

How does clipboard manager's writeImage function work?  #2208

Open
@kaanyalova

Description

@kaanyalova

If i try to write images like the example:

import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
const buffer = [
  // A red pixel
  255, 0, 0, 255,

 // A green pixel
  0, 255, 0, 255,
];
await writeImage(buffer);

I get an error on the webview console
Unhandled Promise Rejection: expected RGBA image data, found raw bytes

If I try to convert an image to RGBA data in rust then pass the buffer I still get the same error

#[tauri::command(async)]
#[specta::specta]
pub fn image_path_to_rgba_bytes(path: &str) -> Vec<u8> {
    let img = image::open(path).unwrap().to_rgba8();
    img.into_raw()
}
const rawImage = await commands.imagePathToRgbaBytes(imagePath);
await writeImage(rawImage);
// Unhandled Promise Rejection: expected RGBA image data, found raw bytes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions