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

Cannot convert from BmpDecoder #114

Open
tronta opened this issue Jan 4, 2022 · 3 comments
Open

Cannot convert from BmpDecoder #114

tronta opened this issue Jan 4, 2022 · 3 comments

Comments

@tronta
Copy link

tronta commented Jan 4, 2022

I used to embed an image like this:

        let image_bytes = include_bytes!("../data/image.bmp");
        let mut image_file = Cursor::new(image_bytes.as_ref());
        let Bmp = image_crate::bmp::BmpDecoder::new(&mut image_file).unwrap();
        let logo = Image::try_from(Bmp).unwrap();

But with the new version I get the following error message when using the try_from:

the trait bound `printpdf::Image: std::convert::From<exporter::document::image_crate::bmp::BmpDecoder<&mut std::io::Cursor<&[u8]>>>` is not satisfied
the following implementations were found:
  <printpdf::Image as std::convert::From<printpdf::ImageXObject>>
required because of the requirements on the impl of `std::convert::Into<printpdf::Image>` for `exporter::document::image_crate::bmp::BmpDecoder<&mut std::io::Cursor<&[u8]>>`
required because of the requirements on the impl of `std::convert::TryFrom<exporter::document::image_crate::bmp::BmpDecoder<&mut std::io::Cursor<&[u8]>>>` for `printpdf::Image`rustcE0277
mod.rs(479, 5): required by `std::convert::TryFrom::try_from`

Anything special I need to do now?

@tronta tronta changed the title Cannot convert from Cannot convert from BmpDecoder Jan 4, 2022
@bastibense
Copy link

Same issue here. Apparently something is broken.

I looked at the examples (image example) and tried the way OP mentioned above.

Something is broken with the dependency on the image_crate dep. Any suggestions or workarounds?

@bastibense
Copy link

After doing some research I defined "embedded_images" as feature in my Cargo.toml.

Sadly I didn't stumble across this in the docs or examples. Only by actually looking at the printpdf sources.

[dependencies]
printpdf = { version = "0.6.0", features = [ "embedded_images" ] }

Maybe that helps.

@fschutt
Copy link
Owner

fschutt commented Nov 2, 2024

In the 0.8 API, the image crate will always be enabled (should solve this issue), but image formats will not be enabled by default. So this should solve this issue.

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

3 participants