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;
}
Aggregations