Search in sources :

Example 1 with WebpTranscoder

use of com.facebook.imagepipeline.nativecode.WebpTranscoder in project fresco by facebook.

the class WebpTranscodeProducer method shouldTranscode.

private static TriState shouldTranscode(final EncodedImage encodedImage) {
    Preconditions.checkNotNull(encodedImage);
    InputStream is = Preconditions.checkNotNull(encodedImage.getInputStream());
    ImageFormat imageFormat = ImageFormatChecker.getImageFormat_WrapIOException(is);
    if (DefaultImageFormats.isStaticWebpFormat(imageFormat)) {
        final WebpTranscoder webpTranscoder = WebpTranscoderFactory.getWebpTranscoder();
        if (webpTranscoder == null) {
            return TriState.NO;
        }
        return TriState.valueOf(!webpTranscoder.isWebpNativelySupported(imageFormat));
    } else if (imageFormat == ImageFormat.UNKNOWN) {
        // in which case the decision whether to transcode or not cannot be made yet
        return TriState.UNSET;
    }
    // if the image format is known, but it is not WebP, then the image shouldn't be transcoded
    return TriState.NO;
}
Also used : InputStream(java.io.InputStream) ImageFormat(com.facebook.imageformat.ImageFormat) WebpTranscoder(com.facebook.imagepipeline.nativecode.WebpTranscoder)

Aggregations

ImageFormat (com.facebook.imageformat.ImageFormat)1 WebpTranscoder (com.facebook.imagepipeline.nativecode.WebpTranscoder)1 InputStream (java.io.InputStream)1