public class

JfifUtil

extends Object
java.lang.Object
   ↳ com.facebook.imageutils.JfifUtil

Class Overview

Util for obtaining information from JPEG file.

Summary

Constants
int APP1_EXIF_MAGIC
int MARKER_APP1
int MARKER_EOI
int MARKER_ESCAPE_BYTE
int MARKER_FIRST_BYTE Definitions of jpeg markers as well as overall description of jpeg file format can be found here: Recommendation T.81
int MARKER_RST0
int MARKER_RST7
int MARKER_SOFn
int MARKER_SOI
int MARKER_SOS
int MARKER_TEM
Public Methods
static int getAutoRotateAngleFromOrientation(int orientation)
Determines auto-rotate angle based on orientation information.
static int getOrientation(byte[] jpeg)
Gets orientation information from jpeg byte array.
static int getOrientation(InputStream is)
Get orientation information from jpeg input stream.
static boolean moveToMarker(InputStream is, int markerToFind)
Reads the content of the input stream until specified marker is found.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int APP1_EXIF_MAGIC

Constant Value: 1165519206 (0x45786966)

public static final int MARKER_APP1

Constant Value: 225 (0x000000e1)

public static final int MARKER_EOI

Constant Value: 217 (0x000000d9)

public static final int MARKER_ESCAPE_BYTE

Constant Value: 0 (0x00000000)

public static final int MARKER_FIRST_BYTE

Definitions of jpeg markers as well as overall description of jpeg file format can be found here: Recommendation T.81

Constant Value: 255 (0x000000ff)

public static final int MARKER_RST0

Constant Value: 208 (0x000000d0)

public static final int MARKER_RST7

Constant Value: 215 (0x000000d7)

public static final int MARKER_SOFn

Constant Value: 192 (0x000000c0)

public static final int MARKER_SOI

Constant Value: 216 (0x000000d8)

public static final int MARKER_SOS

Constant Value: 218 (0x000000da)

public static final int MARKER_TEM

Constant Value: 1 (0x00000001)

Public Methods

public static int getAutoRotateAngleFromOrientation (int orientation)

Determines auto-rotate angle based on orientation information.

Parameters
orientation orientation information, one of {1, 3, 6, 8}.
Returns
  • orientation: 1/3/6/8 -> 0/180/90/270.

public static int getOrientation (byte[] jpeg)

Gets orientation information from jpeg byte array.

Parameters
jpeg the input byte array of jpeg image
Returns
  • orientation: 1/8/3/6. Returns 0 if there is no valid orientation information.

public static int getOrientation (InputStream is)

Get orientation information from jpeg input stream.

Parameters
is the input stream of jpeg image
Returns
  • orientation: 1/8/3/6. Returns {@value android.media.ExifInterface#ORIENTATION_UNDEFINED} if there is no valid orientation information.

public static boolean moveToMarker (InputStream is, int markerToFind)

Reads the content of the input stream until specified marker is found. Marker will be consumed and the input stream will be positioned after the specified marker.

Parameters
is the input stream to read bytes from
markerToFind the marker we are looking for
Returns
  • boolean: whether or not we found the expected marker from input stream.
Throws
IOException