private void doTransform(
        EncodedImage encodedImage, @Status int status, ImageTranscoder imageTranscoder) {
      mProducerContext.getProducerListener().onProducerStart(mProducerContext, PRODUCER_NAME);
      ImageRequest imageRequest = mProducerContext.getImageRequest();
      PooledByteBufferOutputStream outputStream = mPooledByteBufferFactory.newOutputStream();
      Map<String, String> extraMap = null;
      EncodedImage ret;
      try {
        ImageTranscodeResult result =
            imageTranscoder.transcode(
                encodedImage,
                outputStream,
                imageRequest.getRotationOptions(),
                imageRequest.getResizeOptions(),
                null,
                DEFAULT_JPEG_QUALITY,
                encodedImage.getColorSpace());

        if (result.getTranscodeStatus() == TranscodeStatus.TRANSCODING_ERROR) {
          throw new RuntimeException("Error while transcoding the image");
        }

        extraMap =
            this.getExtraMap(
                encodedImage,
                imageRequest.getResizeOptions(),
                result,
                imageTranscoder.getIdentifier());

        CloseableReference<PooledByteBuffer> ref =
            CloseableReference.of(outputStream.toByteBuffer());
        try {
          ret = new EncodedImage(ref);
          ret.setImageFormat(result.getOutputFormat());
          try {
            ret.parseMetaData();
            mProducerContext
                .getProducerListener()
                .onProducerFinishWithSuccess(mProducerContext, PRODUCER_NAME, extraMap);
            if (result.getTranscodeStatus() != TranscodeStatus.TRANSCODING_NO_RESIZING) {
              status |= Consumer.IS_RESIZING_DONE;
            }
            getConsumer().onNewResult(ret, status);
          } finally {
            EncodedImage.closeSafely(ret);
          }
        } finally {
          CloseableReference.closeSafely(ref);
        }
      } catch (Exception e) {
        mProducerContext
            .getProducerListener()
            .onProducerFinishWithFailure(mProducerContext, PRODUCER_NAME, e, extraMap);
        if (isLast(status)) {
          getConsumer().onFailure(e);
        }
        return;
      } finally {
        outputStream.close();
      }
    }
Resizes and rotates images according to the EXIF orientation data or a specified rotation angle.

<p>If the image is not supported by the {@link ImageTranscoder}, no transformation is applied.

<p>This can be used even if downsampling is enabled as long as resizing is disabled.
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/ResizeAndRotateProducer.java