-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Encoder panic #7
Comments
Thanks for letting me know! I'll work on tackling this today |
Also, this line always panics when I trying convert |
@optozorax, your png link 404s for me. Could you try attaching it again so I can test locally against that specific image? |
Thanks! Also, can you share a minumum reproducible example of how you are trying to use the library with this image? |
I'm trying to convert this image to webp with quality 75 and |
The Once you have an MRE I will continue to work on implementation so that you can use this crate for your desired functionality. |
@jaredforth I've run into this through Zola as well, I've extracted it into the following MRE in case it's useful: use image::{imageops::FilterType, EncodableLayout};
use std::fs::File;
use std::io::Write;
fn main() -> Result<(), Box<dyn std::error::Error>> {
const INPUT_PATH: &str = "/path/to/image/on/disk.webp";
let img = image::open(&INPUT_PATH)?;
let img = img.resize_exact(384, 384, FilterType::Lanczos3);
let encoder = webp::Encoder::from_image(&img).unwrap();
let memory = encoder.encode_lossless();
let mut f = File::create("target.webp")?;
f.write_all(memory.as_bytes())?;
Ok(())
} In my case, I'm attempting to convert my profile image (which is already a WebP, exported from Gimp) to smaller sizes so I can add it to my website. Edit: for what it's worth, this is also triggering the |
I dug into this a little bit further. Prior to image-rs/image#1624 (merged recently but still unreleased), the Supported Image Formats section on the
As it turns out, patching out the As for the original example provided by @optozorax, it looks like the original source PNG is encoded as grayscale, so it makes sense that it's being passed in as a It looks like the WebP format has no special encoding for grayscale images, so I think the best approach here is to just use |
@antonok-edm I am just reading through this thread again now. I have improved the error messages so that it is obvious what case is triggering the error. 6e0ca1a |
I'm trying to convert this png to webp, but it panics here:
webp/src/encoder.rs
Line 26 in 81e42aa
The text was updated successfully, but these errors were encountered: