Skip to content
Discussion options

You must be logged in to vote

Hell yeah, it works like this:

async fn get_image_dimensions(
    &self,
    prefix: &str,
    identifier: &str,
) -> Result<(u32, u32)> {
    let file_path = self.get_path(prefix, identifier)?;
    let file = File::open(&file_path).await?;
    let sync_reader = SyncIoBridge::new(BufReader::new(file));
    spawn_blocking(move || {
        ImageFormat::from_path(&file_path)
            .map_err(|e| Error::other(e))
            .and_then(|fmt| {
                let img_reader = ImageReader::with_format(sync_reader, fmt);
                img_reader.into_dimensions().map_err(|e| {
                    Error::other(format!(
                        "Unable to get image dimensions: {e}"

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@197g
Comment options

197g Jan 13, 2026
Maintainer

Answer selected by 197g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2725 on January 13, 2026 08:16.