SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.34k stars 847 forks source link

JPEG Parse Fails If APP0 doesn't immediately follow SOI #2578

Closed QuinnDamerell closed 10 months ago

QuinnDamerell commented 10 months ago

Prerequisites

ImageSharp version

v3.0.2

Other ImageSharp packages and versions

None

Environment (Operating system, version and so on)

Linux

.NET Framework version

dotnet core 7.0

Description

I run a service that processes webcam images from many users. These webcam images come from a variety of webcam servers, some mjpg-streamer, webcam streamer, IP cameras, and more. I have recently encountered an issue where one of the webcam servers seems to be using a weird jpeg image format, where the FF DB (DQT) comes before the FF E0 (APP0). Here's a hex dump of the headers from an image:

image

The ImageSharp lib seems always to need the `FF E0 to follow the FF D8. The fix would be to allow these header-type byte formats to be consumed in different orders.

Steps to Reproduce

Produce a JPEG image with at DQT header and move the DQT header before the APP0 header.

Images

No response

QuinnDamerell commented 10 months ago

Actually, I was incorrect; the issue seems to be fixed with this fix.

https://github.com/SixLabors/ImageSharp/commit/492507fa2d4bcbd77ca638724db1307da99b5bd5

That change was made on Jun 23 of this year, and the latest release is from Aug 29th, do you have any idea when that change will make it to the release branch?

JimBobSquarePants commented 10 months ago

It's going to be part of the v3.1 release which I've targeted to release at the end of the month. You can use our nightly releases in the interim (see readme) if you need it sooner.