Mirror an image
What does it do?
The mirror operation can be used to mirror an image. The image will either be reversed horizontally or vertically.
Mirror a BufferedImage in Java
Add JDeli to your project via Maven or Gradle, or see using JDeli with Java modules.
ImageProcessingOperations uses a builder pattern — chain transformation methods to define how the image should be processed, then pass the object to JDeli.convert() to apply them during format conversion.
ImageProcessingOperations operations = new ImageProcessingOperations();
// Chain multiple operations such as scale, blur, rotate, sharpen, and more
operations.mirror(MirrorOperations.HORIZONTAL); // use MirrorOperations to specify the mirroring operation to use
// Apply the operations to a BufferedImage
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);
View Javadoc for the mirror operation
JDeli.convert() — Input/Output Methods
Pass an ImageProcessingOperations object to any JDeli.convert() overload to apply transformations during conversion. JDeli supports three input/output models:
Using File
Read from and write to disk paths directly.
File inputFile = new File("path/to/file");
File outputFile = new File("path/to/output-mirrored-file");
JDeli.convert(inputFile, outputFile, operations);
Using InputStream and OutputStream
Use for network streams, servlet responses, or any scenario where file paths are unavailable.
final InputStream inputStream = new FileInputStream(inputFile);
final OutputStream outputStream = new FileOutputStream(outputFile);
final String outputFormat = "png"; // Supported formats: avif, bmp, gif, heic, jpeg, pdf, png, tiff, webp
JDeli.convert(inputStream, outputStream, outputFormat, operations);
Using byte[]
Use for in-memory processing pipelines where data is already loaded.
byte[] inputData = Files.readAllBytes(Paths.get("/path/to/file"));
final String outputFormat = "png"; // Supported formats: avif, bmp, gif, heic, jpeg, pdf, png, tiff, webp
byte[] outputData = JDeli.convert(inputData, outputFormat, operations);
Frequently Asked Questions
Can I chain multiple image processing operations together?
Yes. ImageProcessingOperations is a builder — call as many methods as needed before passing the object to JDeli.convert(). Operations are applied in the order they are chained.
Can I apply operations without converting the image format?
Yes. Call operations.apply(BufferedImage originalImage) directly to get a processed BufferedImage without any format conversion.
Which input types does JDeli support for image processing?
JDeli supports File, InputStream/OutputStream, and byte[]. All three overloads of JDeli.convert() accept an ImageProcessingOperations parameter.
What output formats can I convert to when applying operations?
JDeli can write to AVIF, BMP, GIF, HEIC, JPEG, PDF, PNG, TIFF, and WebP when using JDeli.convert() with an ImageProcessingOperations object.