image-rs / imageproc

Image processing operations
MIT License
755 stars 148 forks source link

Outdated examples: can't draw text on an image #492

Closed YassinEldeeb closed 2 years ago

YassinEldeeb commented 2 years ago

Using this example causes the following errors:

$ cargo run
   Compiling deadline v0.1.0 (C:\development\Rust\deadline)
error[E0432]: unresolved import `imageproc::drawing::text_size`
 --> src\main.rs:2:41
  |
2 | use imageproc::drawing::{draw_text_mut, text_size};
  |                                         ^^^^^^^^^ no `text_size` in `drawing`

error[E0277]: the trait bound `ImageBuffer<Rgb<u8>, Vec<u8>>: image::image::GenericImage` is not satisfied
  --> src\main.rs:28:5
   |
28 |     draw_text_mut(&mut image, Rgb([0u8, 0u8, 255u8]), 0, 0, scale, &font, text);
   |     ^^^^^^^^^^^^^ the trait `image::image::GenericImage` is not implemented for `ImageBuffer<Rgb<u8>, Vec<u8>>`
   |
   = note: required because of the requirements on the impl of `Canvas` for `ImageBuffer<Rgb<u8>, Vec<u8>>`

error[E0277]: the trait bound `Rgb<u8>: image::traits::Pixel` is not satisfied
  --> src\main.rs:28:5
   |
28 |     draw_text_mut(&mut image, Rgb([0u8, 0u8, 255u8]), 0, 0, scale, &font, text);
   |     ^^^^^^^^^^^^^ the trait `image::traits::Pixel` is not implemented for `Rgb<u8>`

Some errors have detailed explanations: E0277, E0432.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `deadline` due to 3 previous errors
gregoa commented 2 years ago

Seems to work with image = "0.23.14" (but not with the most recent 0.24.x release)

YassinEldeeb commented 2 years ago

@gregoa Thank you for mentioning a working version, It's a good solution to downgrade at least for now.

liyongjing commented 2 years ago

image = "0.24.0" imageproc = { git = "https://github.com/image-rs/imageproc.git" }

ascodelife commented 2 years ago

@gregoa Thank you for mentioning a working version, It's a good solution to downgrade at least for now.

after downgrading the version of image to 0.23.14, it doesn't work for me. i got the same error as you. image = "=0.23.14" imageproc = "0.22"

ascodelife commented 2 years ago

@gregoa Thank you for mentioning a working version, It's a good solution to downgrade at least for now.

after downgrading the version of image to 0.23.14, it doesn't work for me. i got the same error as you. image = "=0.23.14" imageproc = "0.22"

it works as follow

image = "0.24.1" imageproc = { git = "https://github.com/image-rs/imageproc" }

qqpann commented 2 years ago

When specifying version imageproc = "0.22.0", it seems drawing/mod.rs does not export text_size. It becomes:

mod text;
pub use self::text::{draw_text, draw_text_mut};

However, the example requires text_size and the latest master contains it.

Is 0.22.0 outdated? Is there a newer version or a pre-release version?

qqpann commented 2 years ago

image = "0.24.0" imageproc = { git = "https://github.com/image-rs/imageproc.git" }

For now this works for me, as 0.22.0 seems to be outdated.

theotherphil commented 2 years ago

This is fixed in version 0.23, which I've just published