public static Bitmap resizeBitmapIfNeeded(@NonNull Bitmap bitmap, int width, int height) {
    if (bitmap.getWidth() == width && bitmap.getHeight() == height) {
      return bitmap;
    }
    Bitmap resizedBitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
    bitmap.recycle();
    return resizedBitmap;
  }
Resize the bitmap to exactly the same size as the specified dimension, changing the aspect ratio if needed.
Returns the original bitmap if the dimensions already match.
lottie/src/main/java/com/airbnb/lottie/utils/Utils.java