INNER CODE UNIT · Rust

get_bytes_jpeg

silvia-odwyer/photon · crate/src/lib.rs:220

    pub fn get_bytes_jpeg(&self, quality: u8) -> Vec<u8> {
        let mut buffer = vec![];
        JpegEncoder::new_with_quality(Cursor::new(&mut buffer), quality)
            .write_image(
                &self.raw_pixels,
                self.width,
                self.height,
                image::ColorType::Rgba8,
            )
            .unwrap();
        buffer
    }

    /// Convert the PhotonImage to raw bytes. Returns a WEBP.
    pub fn get_bytes_webp(&self) -> Vec<u8> {
        // write_to owns the lossy/lossless encoder choice, so one clone is
        // the floor here.
        let img = ImageRgba8(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…