SixLabors / SixLabors/ImageSharp

JpegImageFormatDetector IsJfif and IsExif checks are not needed as IsJpeg is always true for valid JPEG files.

Open
#2,805 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs triage
Dominant language
C#
Stars
8k
Forks
899
Avg merge
1d 5h
Merged PRs (30d)
7

Description

Prerequisites
  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported
ImageSharp version

3.1.5

Other ImageSharp packages and versions

3.1.5

Environment (Operating system, version and so on)

Windows

.NET Framework version

.NET 8.0

Description

I was developing a new JPEG-LS (lossless jpeg) codec interop for ImageSharp as the build-in decoder doesn't support it.
I noticed a couple of issues during this development that I like to share. For easy tracking I have a separate report for each issue:

Every valid JPEG file starts with a SOI marker. The JpegImageFormatDetector.cs checks this but also checks if there is a Jfif application segment present or an Exif segment. These 2 checks are redundant as files with an Jfif or Exif segment will also start with a SOI marker.

https://github.com/SixLabors/ImageSharp/blob/4584377879f8e83cd351425c665a9b691047804b/src/ImageSharp/Formats/Jpeg/JpegImageFormatDetector.cs#L25

Steps to Reproduce

N.A. checks are valid, just not really needed.

Images

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/ImageSharp/Formats/Jpeg/JpegImageFormatDetector.cs at the checks linked in the issue. Review the detector's JPEG validation logic and the surrounding tests, then confirm the redundant JFIF and Exif checks are no longer required while valid JPEG detection remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.