imazen / imageflow-dotnet

The official .NET API for Imageflow, the Rust image processing and optimization engine for web servers
GNU Affero General Public License v3.0
143 stars 25 forks source link

Feature request: "IsDecodable(?)" #22

Closed aheintz closed 3 years ago

aheintz commented 3 years ago

I want to be able to determine if a byte stream is decodable, i.e. ImageFlow can scale the binary or not. Without throwing an exception.

In our case, the stored content-type sometimes doesn't match, and I don't want to try to scale an unscalable image since it throws an exception. Current ImageJob.GetImageInfo also throws an exception if no matching encoder is found and exceptions aren't cheap and I would like to just be able to determine if ImageFlow can handle the image or not.

I don't know if this actually should be posted in the imageflow repo though.

lilith commented 3 years ago

It would probably be more efficient to implement this on the .NET side than in Imageflow itself, due to call overhead. I'm considering it.

lilith commented 3 years ago

See ImageJob.CanDecodeBytes() and ImageJob.GetContentTypeForBytes()

lilith commented 3 years ago

Added in https://github.com/imazen/imageflow-dotnet/releases/tag/v0.7.8