/** * Makes a thumbnail of the specified dimensions, from the specified source image. * * @param img The source image. * @param width The target width of the thumbnail. * @param height The target height of the thumbnail. * @return The thumbnail image. * @throws IllegalStateException If the {@code ThumbnailMaker} is not ready to create thumbnails. * @throws IllegalArgumentException If the width and/or height is less than or equal to zero. */ protected BufferedImage makeThumbnail(BufferedImage img, int width, int height) { if (!ready.isReady()) { throw new IllegalStateException(ThumbnailMaker.NOT_READY_FOR_MAKE); } if (width <= 0) { throw new IllegalArgumentException("Width must be greater than zero."); } if (height <= 0) { throw new IllegalArgumentException("Height must be greater than zero."); } BufferedImage thumbnailImage = new BufferedImageBuilder(width, height, imageType).build(); Dimension imgSize = new Dimension(img.getWidth(), img.getHeight()); Dimension thumbnailSize = new Dimension(width, height); Resizer resizer = resizerFactory.getResizer(imgSize, thumbnailSize); resizer.resize(img, thumbnailImage); return thumbnailImage; }