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

Displaying a JPEG image does not work with image crate version higher than 0.24 #4464

Closed
leogomezz4t opened this issue May 5, 2024 · 2 comments
Labels
bug Something is broken

Comments

@leogomezz4t
Copy link

I was recently trying to display a JPEG image in a egui window using eframe but it would consistently say "Image format JPEG not supported". When trying to display a PNG, it worked perfectly however. To be clear, I had already included the jpeg features in my Cargo.toml.

I found the only thing that fixed it was changing the image crate version from 0.25.1 to 0.24.

I am using this test code pulled from the egui image example

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 800.0]),
        ..Default::default()
    };
    eframe::run_native(
        "Image Viewer",
        options,
        Box::new(|cc| {
            // This gives us image support:
            egui_extras::install_image_loaders(&cc.egui_ctx);
            Box::<MyApp>::default()
        }),
    )
}

#[derive(Default)]
struct MyApp {}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            egui::ScrollArea::both().show(ui, |ui| {
                ui.add(
                    egui::Image::new("https://picsum.photos/seed/1.759706314/1024").rounding(10.0),
                );
            });
        });
    }
}

This Cargo.toml doesn't work

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

[dependencies]
eframe = { version = "0.27.2", features = [
    "default"
] }
egui = "0.27.2"
egui_extras = { version = "0.27.2", features = ["default", "all_loaders"] }
# Only difference is the image version is 0.25.1
image = { version = "0.25.1", default-features = false, features = [
    "jpeg",
    "png"
] }

This Cargo.toml does work

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

[dependencies]
eframe = { version = "0.27.2", features = [
  "default",
] }
egui = "0.27.2"
egui_extras = { version = "0.27.2", features = ["default", "all_loaders"] }
# Only difference is the image version is 0.24
image = { version = "0.24", default-features = false, features = [
  "jpeg",
  "png",
] }
@leogomezz4t leogomezz4t added the bug Something is broken label May 5, 2024
@emilk
Copy link
Owner

emilk commented May 6, 2024

You must use the same version of image as egui_extras uses.

See also:

@emilk emilk closed this as completed May 6, 2024
@torokati44
Copy link
Contributor

Just weaving the GH reference net tighter: This is the same fundamental issue as ruffle-rs/ruffle#15836, currently blocked on gltf-rs/gltf#409 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants