Unit test fixes and improvements

This commit is contained in:
Maja Joksovic
2020-06-18 22:52:35 +02:00
parent bc71da5e02
commit ae071e7d71
9 changed files with 74 additions and 253 deletions
@@ -9,7 +9,7 @@ import javax.imageio.ImageIO;
public class Graphics2DExample {
static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException {
static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) {
BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = resizedImage.createGraphics();
graphics2D.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null);
@@ -8,7 +8,7 @@ import java.io.IOException;
import javax.imageio.ImageIO;
public class ImageScaledInstanceExample {
static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException {
static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) {
Image resultingImage = originalImage.getScaledInstance(targetWidth, targetHeight, Image.SCALE_DEFAULT);
BufferedImage bufferedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
bufferedImage.getGraphics()
@@ -8,11 +8,11 @@ import javax.imageio.ImageIO;
import org.imgscalr.Scalr;
public class ImgscalrExample {
public static BufferedImage simpleResizeImage(BufferedImage originalImage, int targetWidth) throws Exception {
public static BufferedImage simpleResizeImage(BufferedImage originalImage, int targetWidth) {
return Scalr.resize(originalImage, targetWidth);
}
public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws Exception {
public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) {
return Scalr.resize(originalImage, Scalr.Method.AUTOMATIC, Scalr.Mode.AUTOMATIC, targetWidth, targetHeight, Scalr.OP_ANTIALIAS);
}
@@ -4,13 +4,14 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.coobird.thumbnailator.Thumbnails;
public class ThumbnailatorExample {
static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws Exception {
static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Thumbnails.of(originalImage)
.size(targetWidth, targetHeight)