Image (@Nullable Image mrImage) { if (!(mrImage instanceof MultiResolutionImage)) { return mrImage; } if (!checkSize(mrImage)) { //noinspection CallToPrintStackTrace new IllegalArgumentException("the image has illegal size 0x0").printStackTrace(); } int width = mrImage.getWidth(null); for (Image img : ((MultiResolutionImage)mrImage).getResolutionVariants()) { if (img.getWidth(null) >= width) { mrImage = img; } } return mrImage; }