code: private RenditionMetadata getVirtualRendition(Set<RenditionMetadata> candidates,
        long destWidth, long destHeight, double destRatio) {
  
      // if ratio is defined get first rendition with matching ratio and same or bigger size
      if (destRatio > 0) {
        for (RenditionMetadata candidate : candidates) {
          if (candidate.matches(destWidth, destHeight, 0, 0, destRatio)) {
            return getVirtualRendition(candidate, destWidth, destHeight, destRatio);
          }
        }
      }
      // otherwise get first rendition which is same or bigger in width and height
      else {
        for (RenditionMetadata candidate : candidates) {
          if (candidate.matches(destWidth, destHeight, 0, 0, 0d)) {
            return getVirtualRendition(candidate, destWidth, destHeight, 0d);
          }
        }
      }
  
      // none found
      return null;
    }
docs: Check if a rendition is available from which the required format can be downscaled from and returns
  a virtual rendition in this case.
  @param candidates Candidates
  @param destWidth Destination width
  @param destHeight Destination height
  @param destRatio Destination ratio
  @return Rendition or null