public class

ImageFormatChecker

extends Object
java.lang.Object
   ↳ com.facebook.imageformat.ImageFormatChecker

Class Overview

Detects the format of an encoded image.

Summary

Public Methods
ImageFormat determineImageFormat(InputStream is)
static ImageFormat getImageFormat(InputStream is)
Tries to read up to MAX_HEADER_LENGTH bytes from InputStream is and use read bytes to determine type of the image contained in is.
static ImageFormat getImageFormat(String filename)
Reads image header from a file indicated by provided filename and determines its format.
static ImageFormat getImageFormat_WrapIOException(InputStream is)
synchronized static ImageFormatChecker getInstance()
Get the currently used instance of the image format checker
void setCustomImageFormatCheckers(List<ImageFormat.FormatChecker> customImageFormatCheckers)
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public ImageFormat determineImageFormat (InputStream is)

Throws
IOException

public static ImageFormat getImageFormat (InputStream is)

Tries to read up to MAX_HEADER_LENGTH bytes from InputStream is and use read bytes to determine type of the image contained in is. If provided input stream does not support mark, then this method consumes data from is and it is not safe to read further bytes from is after this method returns. Otherwise, if mark is supported, it will be used to preserve original content of is.

Returns
  • ImageFormat matching content of is InputStream or UNKNOWN if no type is suitable
Throws
IOException if exception happens during read

public static ImageFormat getImageFormat (String filename)

Reads image header from a file indicated by provided filename and determines its format. This method does not throw IOException if one occurs. In this case, UNKNOWN will be returned.

Returns
  • ImageFormat for image stored in filename

public static ImageFormat getImageFormat_WrapIOException (InputStream is)

public static synchronized ImageFormatChecker getInstance ()

Get the currently used instance of the image format checker

Returns
  • the image format checker to use

public void setCustomImageFormatCheckers (List<ImageFormat.FormatChecker> customImageFormatCheckers)