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

no method named 'dimensions' found for type 'image::DynamicImage' #24

Open
jweinraub opened this issue Jul 15, 2019 · 3 comments
Open

Comments

@jweinraub
Copy link

I just tried to use Termpix and got this error:

error[E0599]: no method named `dimensions` found for type `image::DynamicImage` in the current scope
  --> /home/jonathan/.cargo/git/checkouts/termpix-408ef1586b012b19/c22d061/src/main.rs:53:41
   |
53 |     let (orig_width, orig_height) = img.dimensions();
   |                                         ^^^^^^^^^^
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
   |
8  | use image::GenericImageView;
   |

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: failed to compile `termpix v0.1.0 (https://github.com/hopey-dishwasher/termpix#c22d061f)`, intermediate artifacts can be found at `/tmp/cargo-install9lI6DS`

Caused by:
  Could not compile `termpix`.

@CodingLappen
Copy link

I have that one too. Seems to be pretty new.

@CodingLappen
Copy link

I fixed it, with the Line use image::GenericImageView; right below use:std::io::Write;
And then compiled it normally. Had to copy the executeable to /usr/bin but otherwise it wasn't a problem.

jbregman added a commit to CyGlass/termpix that referenced this issue Nov 22, 2019
@softmarshmallow
Copy link

softmarshmallow commented Feb 18, 2024

I fixed it, with the Line use image::GenericImageView; right below use:std::io::Write; And then compiled it normally. Had to copy the executeable to /usr/bin but otherwise it wasn't a problem.

Short example here for fellas

use image::DynamicImage;
use image::GenericImageView;
use reqwest;

async fn load_image_from_url(url: &str) -> DynamicImage {
    let resp = reqwest::get(url).await.expect("Failed to download image");
    let bytes = resp.bytes().await.expect("Failed to read image bytes");
    image::load_from_memory(&bytes).expect("Failed to decode image")
}

async fn example() {
    let image = load_image_from_url("http://example.com/image.png").await;
    let (width, height) = image.dimensions();
}

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

Successfully merging a pull request may close this issue.

3 participants