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

NoEnabledDecoderFound exception thrown on images #19

Closed thecaptncode closed 4 years ago

thecaptncode commented 4 years ago

I am using Imageflow.net and trying to get image info on a variety of file types. Most seem to work but several of them are failing with the NoEnabledDecoderFound exception even though they appear to be valid test images.

The packages I have installed are Imageflow.net v0.7.1 Imageflow.Native.Runtime.win-x86_64 v.1.4.10rc50 and dependencies.

Here is my code. The stream source is a MemoryStream.

ImageInfo info = ImageJob.GetImageInfo(new StreamSource(msDoc, false)).Result;
int width = (int)info.ImageWidth;
int height = (int)info.ImageHeight;
string ext = info.PreferredExtension;

I am attaching one that would not successfully read and providing links to two others since GitHub limits file attachment extensions. Are there encoders I need to enable? plane

https://homepages.cae.wisc.edu/~ece533/images/barbara.bmp https://file-examples-com.github.io/uploads/2017/10/file_example_TIFF_1MB.tiff

Regards, Greg

lilith commented 4 years ago

What is the full error message you get on each image? The errors list the starting bytes of the file which can be used to distinguish its real type.

On Wed, Sep 2, 2020, 12:33 PM thecaptncode notifications@github.com wrote:

I am using Imageflow.net and trying to get image info on a variety of file types. Most seem to work but several of them are failing with the NoEnabledDecoderFound exception even though they appear to be valid test images.

The packages I have installed are Imageflow.net v0.7.1 Imageflow.Native.Runtime.win-x86_64 v.1.4.10rc50 and dependencies.

Here is my code. The stream source is a MemoryStream.

ImageInfo info = ImageJob.GetImageInfo(new StreamSource(msDoc, false)).Result;int width = (int)info.ImageWidth;int height = (int)info.ImageHeight;string ext = info.PreferredExtension;

I am attaching one that would not successfully read and providing links to two others since GitHub limits file attachment extensions. Are there encoders I need to enable? [image: plane] https://user-images.githubusercontent.com/44200625/92021151-509a0500-ed27-11ea-99a3-21b8061e3218.gif

https://homepages.cae.wisc.edu/~ece533/images/barbara.bmp http://url

https://file-examples-com.github.io/uploads/2017/10/file_example_TIFF_1MB.tiff http://url

Regards, Greg

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet/issues/19, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH6CQSD5PNGWE2E4F73SD2FXBANCNFSM4QTQFYOQ .

thecaptncode commented 4 years ago

The bitmap image throws this:

ImageMalformed: NoEnabledDecoderFound: No ENABLED decoder found for file starting in [42, 4D, 36, 4, 4, 0, 0, 0, 0, 0, 36, 4] at
imageflow_core\src\codecs\mod.rs:153:20
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\codecs\mod.rs#L153
imageflow_core\src\context.rs:133:103
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\context.rs#L133
imageflow_core\src\context.rs:174:66
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\context.rs#L174
imageflow_abi\src\lib.rs:707:62
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_abi\src\lib.rs#L707

The gif throws this:

ImageMalformed: NoEnabledDecoderFound: No ENABLED decoder found for file starting in [42, 4D, FE, AF, 0, 0, 0, 0, 0, 0, 36, 0] at
imageflow_core\src\codecs\mod.rs:153:20
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\codecs\mod.rs#L153
imageflow_core\src\context.rs:133:103
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\context.rs#L133
imageflow_core\src\context.rs:174:66
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\context.rs#L174
imageflow_abi\src\lib.rs:707:62
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_abi\src\lib.rs#L707

The tiff throws this:

ImageMalformed: NoEnabledDecoderFound: No ENABLED decoder found for file starting in [49, 49, 2A, 0, D8, 37, 11, 0, D7, 55, 2, FF] at
imageflow_core\src\codecs\mod.rs:153:20
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\codecs\mod.rs#L153
imageflow_core\src\context.rs:133:103
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\context.rs#L133
imageflow_core\src\context.rs:174:66
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_core\src\context.rs#L174
imageflow_abi\src\lib.rs:707:62
https://github.com/imazen/imageflow/blob/1a7e1eecd8f04cab4413b48c2bf8bd5bbf140f5d/imageflow_abi\src\lib.rs#L707

All of that jives with what the first bytes of the files actually are. These are all test image files my testers found on the internet.

Thanks! Greg

lilith commented 4 years ago

The supposed GIF is also a BMP file, thus the error. GIF images start with the letters "GIF".

Imageflow does not support .tiff files nor raw bitmaps, so you'll need to convert them to PNG format for Imageflow to work with them.

thecaptncode commented 4 years ago

That makes sense. I did not realize Imageflow didn't support tiff and raw bitmaps. Is that functionality planned for the future?

lilith commented 4 years ago

We might add raw bitmap support eventually but tiff support is not planned due to the security issues involved.

On Thu, Sep 3, 2020, 5:12 PM thecaptncode notifications@github.com wrote:

That makes sense. I did not realize Imageflow didn't support tiff and raw bitmaps. Is that functionality planned for the future?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet/issues/19#issuecomment-686809991, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH7KQYBBQMTNCZB4MGTSEAPHHANCNFSM4QTQFYOQ .

thecaptncode commented 4 years ago

Today I learned about the tiff security vulnerabilities allowing arbitrary code execution. Thank you very much for the information and your quick response.

lilith commented 4 years ago

Yeah there have been 174 vulnerabilities in libtiff: https://www.cvedetails.com/vulnerability-list/vendor_id-2224/Libtiff.html

On Thu, Sep 3, 2020, 5:29 PM thecaptncode notifications@github.com wrote:

Today I learned about the tiff security vulnerabilities allowing arbitrary code execution. Thank you very much for the information and your quick response.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet/issues/19#issuecomment-686814971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH46MFNSOPXE5KYRRWTSEARGRANCNFSM4QTQFYOQ .

thecaptncode commented 4 years ago

I saw several listed but not that many. Wow. Since we let our users upload images, I need to detect and disallow tiffs by inspecting the first bytes. It looks like there are two possible headers in tiffs: 49 49 2A 00 or 4D 4D 00 2A