Identify the format of an image by looking at its extension.
Its ImageFormat, or ImageFormat.unknown in case of identification failure or input error. Maybe then you can try identifyFormatFromFile instead, which minimally reads the input.
See Implementation
Identify the format of an image by looking at its extension.