public class

NativeJpegTranscoder

extends Object
implements ImageTranscoder
java.lang.Object
   ↳ com.facebook.imagepipeline.nativecode.NativeJpegTranscoder

Class Overview

Transcoder for jpeg images, using native code and libjpeg-turbo library.

Summary

Constants
String TAG
Public Constructors
NativeJpegTranscoder(boolean resizingEnabled, int maxBitmapSize, boolean useDownsamplingRatio, boolean ensureTranscoderLibraryLoaded)
Public Methods
boolean canResize(EncodedImage encodedImage, RotationOptions rotationOptions, ResizeOptions resizeOptions)
Whether the input image is resized to make subsequent decodings faster.
boolean canTranscode(ImageFormat imageFormat)
Whether the input ImageFormat can be transcoded by the image transcoder.
String getIdentifier()
Gets the identifier of the image transcoder.
ImageTranscodeResult transcode(EncodedImage encodedImage, OutputStream outputStream, RotationOptions rotationOptions, ResizeOptions resizeOptions, ImageFormat outputFormat, Integer quality)
Transcodes an image to match the specified rotation and resize options.
static void transcodeJpeg(InputStream inputStream, OutputStream outputStream, int rotationAngle, int scaleNumerator, int quality)
Transcodes an image to match the specified rotation angle and the scale factor.
static void transcodeJpegWithExifOrientation(InputStream inputStream, OutputStream outputStream, int exifOrientation, int scaleNumerator, int quality)
Transcodes an image to match the specified exif orientation and the scale factor.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.facebook.imagepipeline.transcoder.ImageTranscoder

Constants

public static final String TAG

Constant Value: "NativeJpegTranscoder"

Public Constructors

public NativeJpegTranscoder (boolean resizingEnabled, int maxBitmapSize, boolean useDownsamplingRatio, boolean ensureTranscoderLibraryLoaded)

Public Methods

public boolean canResize (EncodedImage encodedImage, RotationOptions rotationOptions, ResizeOptions resizeOptions)

Whether the input image is resized to make subsequent decodings faster.

Parameters
encodedImage The EncodedImage that will be transcoded.
rotationOptions The RotationOptions used when transcoding the image.
resizeOptions The ResizeOptions used when transcoding the image.
Returns
  • true if the image is resized, else false.

public boolean canTranscode (ImageFormat imageFormat)

Whether the input ImageFormat can be transcoded by the image transcoder.

Parameters
imageFormat The ImageFormat that will be transcoded.
Returns
  • true if this image format is handled by the image transcoder, else false.

public String getIdentifier ()

Gets the identifier of the image transcoder. This is mostly used for logging purposes.

Returns
  • the identifier of the image transcoder.

public ImageTranscodeResult transcode (EncodedImage encodedImage, OutputStream outputStream, RotationOptions rotationOptions, ResizeOptions resizeOptions, ImageFormat outputFormat, Integer quality)

Transcodes an image to match the specified rotation and resize options. The most common-use case is to create a resized version of an input image to make subsequent decodings faster.

Parameters
encodedImage The EncodedImage that will be transcoded.
outputStream The OutputStream where the newly created image is written to.
rotationOptions The RotationOptions used when transcoding the image.
resizeOptions The ResizeOptions used when transcoding the image.
outputFormat The desired ImageFormat of the newly created image. If this is null the same format as the input image will be used.
quality The desired quality of the newly created image. If this is null, the default quality of the transcoder will be applied.
Returns
Throws
IOException

public static void transcodeJpeg (InputStream inputStream, OutputStream outputStream, int rotationAngle, int scaleNumerator, int quality)

Transcodes an image to match the specified rotation angle and the scale factor.

Parameters
inputStream The InputStream of the image that will be transcoded.
outputStream The OutputStream where the newly created image is written to.
rotationAngle 0, 90, 180 or 270
scaleNumerator 1 - 16, image will be scaled using scaleNumerator/8 factor
quality 1 - 100
Throws
IOException

public static void transcodeJpegWithExifOrientation (InputStream inputStream, OutputStream outputStream, int exifOrientation, int scaleNumerator, int quality)

Transcodes an image to match the specified exif orientation and the scale factor.

Parameters
inputStream The InputStream of the image that will be transcoded.
outputStream The OutputStream where the newly created image is written to.
exifOrientation 0, 90, 180 or 270
scaleNumerator 1 - 16, image will be scaled using scaleNumerator/8 factor
quality 1 - 100
Throws
IOException