@Test public void testResizeImage() throws IOException { ImageScaler scaler; byte[] data; for (ImageFormatType type : ImageFormatType.values()) { scaler = new ImageScaler(landscapeHeight, landscapeWidth, type); data = scaler.resizeImage(createImage(240, 80)); checkResult(data, landscapeWidth, landscapeHeight); data = scaler.resizeImage(createImage(100, 190)); checkResult(data, landscapeWidth, landscapeHeight); data = scaler.resizeImage(createImage(600, 150)); checkResult(data, landscapeWidth, landscapeHeight); data = scaler.resizeImage(createImage(550, 260)); checkResult(data, landscapeWidth, landscapeHeight); data = scaler.resizeImage(createImage(400, 640)); checkResult(data, landscapeWidth, landscapeHeight); scaler = new ImageScaler(portraitHeight, portraitWidth, type); data = scaler.resizeImage(createImage(240, 300)); checkResult(data, portraitWidth, portraitHeight); data = scaler.resizeImage(createImage(100, 300)); checkResult(data, portraitWidth, portraitHeight); data = scaler.resizeImage(createImage(700, 300)); checkResult(data, portraitWidth, portraitHeight); data = scaler.resizeImage(createImage(400, 840)); checkResult(data, portraitWidth, portraitHeight); data = scaler.resizeImage(createImage(290, 435)); checkResult(data, portraitWidth, portraitHeight); data = scaler.resizeImage(createImage(2500, 10)); checkResult(data, portraitWidth, portraitHeight); } }
public byte[] resizeImage(byte[] data) { BufferedImage image = ImageHelper.byteToImage(data); if (image != null) { if (image.getHeight() > height || image.getWidth() > width) { image = scaleImage(image, height, width, sameAspectRatio); } if (drawBackground) { image = drawBackgroundToImage(image); } } byte[] result = convertImageToBytes(image); if (result != null) { result = ImageHelper.copyExifOrientation(data, result); } return result; }
ImageScaler { public byte[] resizeImage(byte[] data) { BufferedImage image = ImageHelper.byteToImage(data); if (image != null) { if (image.getHeight() > height || image.getWidth() > width) { image = scaleImage(image, height, width, sameAspectRatio); } if (drawBackground) { image = drawBackgroundToImage(image); } } byte[] result = convertImageToBytes(image); if (result != null) { result = ImageHelper.copyExifOrientation(data, result); } return result; } }
ImageScaler { public byte[] resizeImage(byte[] data) { BufferedImage image = ImageHelper.byteToImage(data); if (image != null) { if (image.getHeight() > height || image.getWidth() > width) { image = scaleImage(image, height, width, sameAspectRatio); } if (drawBackground) { image = drawBackgroundToImage(image); } } byte[] result = convertImageToBytes(image); if (result != null) { result = ImageHelper.copyExifOrientation(data, result); } return result; } ImageScaler(ImageSize size, ImageFormatType imageFormatType);  ImageScaler(int height, int width, ImageFormatType imageFormatType); }
ImageScaler { public byte[] resizeImage(byte[] data) { BufferedImage image = ImageHelper.byteToImage(data); if (image != null) { if (image.getHeight() > height || image.getWidth() > width) { image = scaleImage(image, height, width, sameAspectRatio); } if (drawBackground) { image = drawBackgroundToImage(image); } } byte[] result = convertImageToBytes(image); if (result != null) { result = ImageHelper.copyExifOrientation(data, result); } return result; } ImageScaler(ImageSize size, ImageFormatType imageFormatType);  ImageScaler(int height, int width, ImageFormatType imageFormatType); ImageFormatType getFormatType(); int getHeight(); int getWidth(); boolean isDrawBackground(); boolean isSameAspectRatio(); byte[] resizeImage(byte[] data); void setBackgroundColor(Color backgroundColor); void setDimension(ImageSize size); void setDrawBackground(boolean drawBackground); void setFormatType(ImageFormatType formatType); void setHeight(int height); void setHorizontalAlignment(int alignment); void setSameAspectRatio(boolean sameAspectRatio); void setVerticalAlignment(int alignment); void setWidth(int width); }
ImageScaler { public byte[] resizeImage(byte[] data) { BufferedImage image = ImageHelper.byteToImage(data); if (image != null) { if (image.getHeight() > height || image.getWidth() > width) { image = scaleImage(image, height, width, sameAspectRatio); } if (drawBackground) { image = drawBackgroundToImage(image); } } byte[] result = convertImageToBytes(image); if (result != null) { result = ImageHelper.copyExifOrientation(data, result); } return result; } ImageScaler(ImageSize size, ImageFormatType imageFormatType);  ImageScaler(int height, int width, ImageFormatType imageFormatType); ImageFormatType getFormatType(); int getHeight(); int getWidth(); boolean isDrawBackground(); boolean isSameAspectRatio(); byte[] resizeImage(byte[] data); void setBackgroundColor(Color backgroundColor); void setDimension(ImageSize size); void setDrawBackground(boolean drawBackground); void setFormatType(ImageFormatType formatType); void setHeight(int height); void setHorizontalAlignment(int alignment); void setSameAspectRatio(boolean sameAspectRatio); void setVerticalAlignment(int alignment); void setWidth(int width);  }