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

Function to ask for supported image formats/extensions #1994

Closed
emilk opened this issue Aug 28, 2023 · 3 comments
Closed

Function to ask for supported image formats/extensions #1994

emilk opened this issue Aug 28, 2023 · 3 comments

Comments

@emilk
Copy link
Contributor

emilk commented Aug 28, 2023

I would like to be able to ask image what file extensions it supports give its current feature flags.

For instance: println("{:?}", image::extensions()); could print ["jpg", "jpeg", "png"] if only the image and jpeg features of image is turned on.

My specific use case for this functionality is adding file extension filters to a file dialog.

@fintelia
Copy link
Contributor

fintelia commented Sep 1, 2023

I think it makes sense to expose this information. Maybe something like:

impl ImageFormat {
    pub fn reading_enabled(&self) -> bool;
    pub fn writing_enabled(&self) -> bool; 
}

Though we should probably provide a way to iterate over all the formats. I wonder if a method like fn all() -> impl Iterator<Item=ImageFormat> would be good?

@emilk
Copy link
Contributor Author

emilk commented Sep 1, 2023

Oh yeah, great catch on the read vs write difference. That API looks solid to me!

xweskingx pushed a commit to xweskingx/image that referenced this issue Oct 24, 2023
fintelia added a commit that referenced this issue Oct 24, 2023
#1994 - Support for iterating enabled image formats
@fintelia
Copy link
Contributor

Added in #2038

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants