Skip to content

Any way to get supported file extensions? #1353

Answered by tocsoft
cmeeren asked this question in Q&A
Discussion options

You must be logged in to vote

You can get a list of all file extensions (with image decoders) registered against the configured image formats using this:

// For simple cases where you are not specifying a custom Configuration
SixLabors.ImageSharp.Configuration config = SixLabors.ImageSharp.Configuration.Default;

// if using IamgeSharp.Web you will want to resolve by getting a refernece to `ImageSharpMiddlewareOptions` 
//.from DI and the reading the Configuration property from it.

var allSupportedExtensions = config.ImageFormats
    .Where(x=> config.ImageFormatsManager.FindDecoder(x) != null) // we can decode this format (i.e. its not an encode only format)
    .SelectMany(x => x.FileExtensions);

Replies: 2 comments 17 replies

Comment options

You must be logged in to vote
7 replies
@cmeeren
Comment options

@antonfirsov
Comment options

@cmeeren
Comment options

@JimBobSquarePants
Comment options

@cmeeren
Comment options

Comment options

You must be logged in to vote
10 replies
@Susko3
Comment options

@JimBobSquarePants
Comment options

@cmeeren
Comment options

@antonfirsov
Comment options

@JimBobSquarePants
Comment options

Answer selected by cmeeren
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants