Link

Stretch to Fill

What does it do?

The stretch to Fill operation will stretch the image so that it fills the defined pixel rectangle. Aspect ratio is not preserved so the image is stretched and will end up being the width and height specified.

Stretch a BufferedImage in Java

ImageProcessingOperations operations = new ImageProcessingOperations();

// You can chain several operations here such as scale, blur, etc
operations.stretchToFill(100, 100); // make image fill into a box 100x100 pixels
        
// Apply the operations to a BufferedImage
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);

View Javadoc for the stretch to fill 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-stretched-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);

Start Your Free Trial


Customer Downloads