Link

Scale an image

What does it do?

Scale operation will resize the image by the provided scaling factor specified as a double. The default scaling option used is AffineTransformOp.TYPE_BILINEAR.

Scale a BufferedImage in Java

ImageProcessingOperations operations = new ImageProcessingOperations();

// You can chain several operations here such as scale, blur, etc
operations.scale(1.2); //this will use AffineTransformOp.TYPE_BILINEAR
//operations.scale(scalingFactor, AffineTransformOp.TYPE_BICUBIC); //AffineTransformOp.VALUE
        
// Apply the operations to a BufferedImage
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);

View Javadoc for the scale operation

Additional Code Examples

Process and convert between image formats using the following code examples:

Using File

File inputFile = new File("path/to/file");
File outputFile = new File("path/to/output-scaled-file");
JDeli.convert(inputFile, outputFile, operations);

Using InputStream and OutputSteam

final InputStream inputStream = new FileInputStream(inputFile);
final OutputStream outputStream = new FileOutputStream(outputFile);
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
JDeli.convert(inputStream, outputStream, outputFormat, operations);

Using byte[]

byte[] inputData = Files.readAllBytes(Paths.get("/path/to/file"));
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
byte[] outputData = JDeli.convert(inputData, outputFormat, operations);