Skip to content

Image.Identify throws ArgumentNullException if passed an empty byte span #3009

@mikethea1

Description

@mikethea1

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.12

Other ImageSharp packages and versions

n/a

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

.NET 8

Description

I would expect UnknownImageFormatException, but you get ArgumentNullException instead. This doesn't seem appropriate because there is no null pointer at the API boundary and because I'd want to catch UnknownImageFormatException specifically to capture all failed detections.

Steps to Reproduce

Image.Identify(new byte[1]); // throws UnknownImageFormatException
Image.Identify(new byte[0]); // throws ArgumentNullException (Value cannot be null. (Parameter 'pointer')

Images

n/a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions