code: public static Bitmap loadThumbnail(@NonNull final File file, final int maxWidth,
                                         final int maxHeight) throws IOException {
          Pair<Integer, Integer> imageDimensions = getImageDimensions(file);
          int sampleSize = getSampleSize(imageDimensions, maxWidth, maxHeight);
          BitmapFactory.Options options = new BitmapFactory.Options();
          options.inJustDecodeBounds = false;
          options.inSampleSize = sampleSize;
          String path = file.getAbsolutePath();
          Bitmap thumbnail = BitmapFactory.decodeFile(path, options);
  
          if (thumbnail == null) {
              throw new IOException("Failed to decode image \"" + path + "\"");
          }
  
          return thumbnail;
      }
docs: Loads a downsampled thumbnail of a specific image file while maintaining its aspect ratio.
  
  @param file
  The image file, which should be loaded, as an instance of the class {@link File}. The
  file may not be null. The file must exist and must not be a directory
  @param maxWidth
  The maximum width of the thumbnail in pixels as an {@link Integer} value. The maximum
  width must be at least 1
  @param maxHeight
  The maximum height of the thumbnail in pixels as an {@link Integer} value. The
  maximum height must be at least 1
  @return The thumbnail, which has been loaded, as an instance of the class {@link Bitmap}
  @throws IOException
  The exception, which is thrown, if an error occurs while decoding the image file