code: private static int getSampleSize(@NonNull final Pair<Integer, Integer> imageDimensions,
                                       final int maxWidth, final int maxHeight) {
          Condition.INSTANCE.ensureNotNull(imageDimensions, "The image dimensions may not be null");
          Condition.INSTANCE.ensureAtLeast(maxWidth, 1, "The maximum width must be at least 1");
          Condition.INSTANCE.ensureAtLeast(maxHeight, 1, "The maximum height must be at least 1");
          int width = imageDimensions.first;
          int height = imageDimensions.second;
          int sampleSize = 1;
  
          if (width > maxWidth || height > maxHeight) {
              int halfWidth = width / 2;
              int halfHeight = height / 2;
  
              while ((halfWidth / sampleSize) > maxWidth && (halfHeight / sampleSize) > maxHeight) {
                  sampleSize *= 2;
              }
          }
  
          return sampleSize;
      }
docs: Calculates the sample size, which should be used to downsample an image to a maximum width
  and height.
  
  @param imageDimensions
  A pair, which contains the width and height of the image, which should be
  downsampled, as an instance of the class Pair. The pair may not be null
  @param maxWidth
  The maximum width in pixels as an {@link Integer} value. The maximum width must be at
  least 1
  @param maxHeight
  The maximum height in pixels as an{@link Integer} value. The maximum height must be
  at least 1
  @return The sample size, which has been calculated, as an {@link Integer} value