Convert a .webp to .png


does anyone have an idea how to convert a .webp to a .png?
I found this crate but I am not sure if I can convert pictures with it.

image has a partial webp implementation in pure Rust but it only supports loading of grayscale part of lossy webp.
I’ve made a binding
to the C library for my purpose but it doesn’t have a good documentation and has unnecessary dependencies. I’m going to remake it at but the project is currently stale. Nevertheless it will suffice your need to decode webp images into typical RGBA representations.

sounds good. do you maybe have an example for me? Sorry I am not very fit at Rust at the moment…

you described how to unwrap the picture if you have the correct representation

let data = b"\

How do I get that if I already have a picture on my laptop?

I don’t know if its correct what I have done so far?

extern crate libwebp;
extern crate image;

use ::std::{*, io::Write, fs::OpenOptions,};
use std::io::Read;
use libwebp::*;
use std::fs::File;
use std::path::Path;
use std::fmt::Debug;

fn main() -> io::Result<()>
    let src = "/home/andy/Downloads/8Z.ktnc9tqX.mri";
    let dst = "/home/andy/Downloads/8Z.ktnc9tqX";

    let mut data = fs::read(src)?;
    let n = data.len() + 7;
    let header = [
        82, 73, 70, 70, n as u8, (n >> 8) as u8, (n >> 16) as u8, (n >> 24) as u8, 87, 69, 66, 80, 86, 80, 56,

    data.iter_mut().for_each(|at_x| *at_x ^= 101); // more efficient

    let newdst = format!("{}.webp", dst);
    let mut f =

    let mut data = File::open(newdst).unwrap();

    let size = data.metadata().unwrap().len() as usize;

    let mut buf = vec![0u8; size]; buf).unwrap();

    let (width, height, d) = WebPDecodeRGBA(&buf).unwrap();

    println!("{} {}", width, height);

    //image::save_buffer("image.png", &d, width, height, image::RGB(8)).unwrap();

    let format = image::guess_format(&d);

    println!("{:?}", format);


Pretty sure I did something wrong because if I run the image::save_buffer line I get the following error:

thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: Custom { kind: Other, error: StringError(“wrong data size, expected 3544800 got 4726400”) }’, src/libcore/