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

image-rs example not working with newer versions of image #9

Open
marcomastri opened this issue Oct 4, 2022 · 1 comment
Open

image-rs example not working with newer versions of image #9

marcomastri opened this issue Oct 4, 2022 · 1 comment

Comments

@marcomastri
Copy link

See image-rs/image#1477

error[E0277]: the trait bound `Writer<BytesMut>: Seek` is not satisfied
   --> src/main.rs:70:22
    |
70  |         img.write_to(&mut out, out_format).expect("image encoded");
    |             -------- ^^^^^^^^ the trait `Seek` is not implemented for `Writer<BytesMut>`
    |             |
    |             required by a bound introduced by this call
    |
    = help: the following other types implement trait `Seek`:
              &File
              &mut S
              Box<S>
              BufReader<R>
              BufWriter<W>
              File
              std::io::Cursor<T>
              std::io::Empty
note: required by a bound in `DynamicImage::write_to`
   --> /Users/marco-bunker/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.4/./src/dynimage.rs:809:32
    |
809 |     pub fn write_to<W: Write + Seek, F: Into<ImageOutputFormat>>(
    |                                ^^^^ required by this bound in `DynamicImage::write_to`

For more information about this error, try `rustc --explain E0277`.
@marcomastri marcomastri changed the title image-rs example not working wit newer versions of image image-rs example not working with newer versions of image Oct 4, 2022
@marcomastri
Copy link
Author

Wanting to stay close to the example, I made it work by replacing

let mut out = BytesMut::new().writer();
img.write_to(&mut out, out_format).expect("image encoded");
let out = out.into_inner().freeze();

with

let mut out = vec![];
img.write_to(&mut Cursor::new(&mut out), out_format).expect("image encoded");
let out = Bytes::from(out);

but I’m just dipping my toes in rust, and inexperienced with programming in general.

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

1 participant