Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The encoder or decoder for Jpeg does not support the color type Rgba8 #2211

Open
voratham opened this issue Apr 21, 2024 · 1 comment

Comments

@voratham
Copy link

voratham commented Apr 21, 2024

I want to use the DynamicImage.thumbnail method but I got the error Error: The encoder or decoder for Jpeg does not support the color type Rgba8".

Here is an example of the code below:

use image::io::Reader as ImageReader;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let img_original = ImageReader::open("02.png")?.decode()?;

    img_original.thumbnail(100, 100);
    img_original.save("02.jpg")?;

    Ok(())
}

My Cargo.toml

[package]
name = "demo_image_lib"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.82"
image = "0.25.1"
tokio = { version = "1.37.0", features = ["full"] }
@fintelia
Copy link
Contributor

The JPEG file format doesn't support alpha, but your image has an alpha channel. You can either remove the alpha channel (via to_rgb8) or use a different file format that does support alpha. Previous versions of this library used to silently drop the alpha channel

link2xt added a commit to deltachat/deltachat-core-rust that referenced this issue Apr 23, 2024
Otherwise an error
"The encoder or decoder for Jpeg does not support the color type `Rgba8`"
is returned if image has an alpha channel.

This is caused by the recent change of JPEG encoder
in `image` crate: <image-rs/image#2211>
link2xt added a commit to deltachat/deltachat-core-rust that referenced this issue Apr 23, 2024
Otherwise an error
"The encoder or decoder for Jpeg does not support the color type `Rgba8`"
is returned if image has an alpha channel.

This is caused by the recent change of JPEG encoder
in `image` crate: <image-rs/image#2211>
link2xt added a commit to deltachat/deltachat-core-rust that referenced this issue Apr 23, 2024
Otherwise an error
"The encoder or decoder for Jpeg does not support the color type `Rgba8`"
is returned if image has an alpha channel.

This is caused by the recent change of JPEG encoder
in `image` crate: <image-rs/image#2211>
link2xt added a commit to deltachat/deltachat-core-rust that referenced this issue Apr 23, 2024
Otherwise an error
"The encoder or decoder for Jpeg does not support the color type `Rgba8`"
is returned if image has an alpha channel.

This is caused by the recent change of JPEG encoder
in `image` crate: <image-rs/image#2211>
@fintelia fintelia pinned this issue Apr 26, 2024
hagenest pushed a commit to deltachat/deltachat-core-rust that referenced this issue Apr 30, 2024
Otherwise an error
"The encoder or decoder for Jpeg does not support the color type `Rgba8`"
is returned if image has an alpha channel.

This is caused by the recent change of JPEG encoder
in `image` crate: <image-rs/image#2211>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants