Unit test fixes and improvements
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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()
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user