Assertion failing during copy
ynbh opened this issue · comments
ynbh commented
Heya! Rust noob here. I was trying to make a basic CLI app, and came across an issue while using arboard for copying the image to clipboard.
For some reason, every time I try to copy an image, it throws me this error:
thread 'main' panicked at 'assertion failed: !result.is_null()
I don't know what I'm doing wrong, but here's the code for it:
use arboard::{Clipboard, ImageData};
use imagesize::size;
use std::fs;
fn main() {
let mut ctx = Clipboard::new().unwrap();
let file_path = "./temp/Q0w4OleUkPoTRS7KGCZIJP1LV7fZPT.jpg";
let contents = fs::read(file_path).expect("Should have been able to read the file");
let (width, height) = match size(file_path) {
Ok(dim) => (dim.width, dim.height),
Err(_why) => (19, 19),
};
let img_data = ImageData {
height,
width,
bytes: std::borrow::Cow::Borrowed(contents.as_ref()),
};
ctx.set_image(img_data).unwrap();
println!("Done!")
}
Help towards the right direction would be appreciated! Thanks!