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

Guess image format on image::Handle::Path load #2689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SoulSharer
Copy link

Currently there is an inconsistency with image loading. If Image is loaded from bytes image::Handle::from_bytes(bytes) - format is guessed by content, but with image::Handle::from_path(path) it is guessed by file extension, which might not be present.

In the comments it is said to examine the data in the file.

/// Creates an image [`Handle`] pointing to the image of the given path.
///
/// Makes an educated guess about the image format by examining the data in the file.
pub fn from_path<T: Into<PathBuf>>(path: T) -> Handle {
    let path = path.into();

    Self::Path(Id::path(&path), path)
}

So this PR fixes this inconsistency to guess the format by contents instead.

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 this pull request may close these issues.

1 participant