Browse our Products
Aspose.Imaging for JAVA 26.12 - Release notes
Competitive features:
- Add deferred operations pipeline class
- Support PS blending modes in image blending process
| Key | Summary | Category |
|---|---|---|
| IMAGINGJAVA-9338 | Add deferred operations pipeline class | Feature |
| IMAGINGJAVA-9337 | Support PS blending modes in image blending process | Feature |
| IMAGINGJAVA-9356 | Fix oversaturated result on monochrome AVIF images export to other formats | Enhancement |
| IMAGINGJAVA-9355 | Move Comparers to the Public API | Enhancement |
| IMAGINGJAVA-9342 | Fix crop defects on AVIF image export | Enhancement |
| IMAGINGJAVA-9341 | EMF to SVG: Output file is not rendered correctly | Enhancement |
Public API changes:
Added APIs:
Please see corresponding cumulative API changes for Aspose.Imaging for .NET 26.12 version
Removed APIs:
Please see corresponding cumulative API changes for Aspose.Imaging for .NET 26.12 version
Usage Examples:
IMAGINGJAVA-9356 Fix oversaturated result on monochrome AVIF images export to other formats
The exported image should have no significant defects.
try (AvifImage image = (AvifImage)Image.load(inputPath))
{
image.save(outputPath, new PngOptions());
}
{IMAGINGJAVA-9355 Move Comparers to the Public API
import com.aspose.imaging.*;
import com.aspose.imaging.comparers.IImageComparerResult;
import com.aspose.imaging.comparers.ImageComparer;
import com.aspose.imaging.comparers.PsnrComparerResult;
import com.aspose.imaging.comparers.options.BinaryComparerOptions;
import com.aspose.imaging.comparers.options.NccComparerOptions;
import com.aspose.imaging.comparers.options.PsnrComparerOptions;
import com.aspose.imaging.comparers.options.RgbComparerOptions;
import com.aspose.imaging.imagefilters.filteroptions.BlendingMode;
/**
* Sample “Main?style” client code for {@link ImageComparer}.
*/
public final class ImageComparerExamples
{
private ImageComparerExamples() { /* utility class */ }
/** NCC file comparison with a pass/fail threshold. */
public static void compareFilesUsingNcc()
{
String outputPath = "C:/images/output.png";
String referencePath = "C:/images/reference.png";
IImageComparerResult result = ImageComparer.compare(
outputPath,
referencePath,
new NccComparerOptions());
System.out.printf("NCC similarity: %.2f%%%n\n", result.getSimilarityPercent());
if (result.getSimilarityPercent() < 95) {
throw new IllegalStateException("Images differ more than allowed.");
}
}
/** Tile?based PSNR file comparison. */
public static void compareFilesUsingPsnr()
{
String outputPath = "C:/images/output.png";
String referencePath = "C:/images/reference.png";
PsnrComparerOptions options = new PsnrComparerOptions();
options.setTileWidth(32);
options.setTileHeight(32);
PsnrComparerResult result = (PsnrComparerResult) ImageComparer.compare(
outputPath,
referencePath,
options);
System.out.printf("PSNR similarity: %.2f%%\n", result.getSimilarityPercent());
System.out.printf("PSNR: %.2f dB\n", result.getDecibels());
}
/** RGB comparison of loaded raster images. */
public static void compareRasterImagesUsingRgb()
{
try (RasterImage output = (RasterImage) Image.load("C:/images/output.png");
RasterImage reference = (RasterImage) Image.load("C:/images/reference.png")) {
RgbComparerOptions options = new RgbComparerOptions();
options.setMaxChannelDifference((byte) 10);
options.setMaxDifferencePercent(5.0);
IImageComparerResult result = ImageComparer.compare(output, reference, options);
System.out.printf("RGB similarity: %.2f%%\n", result.getSimilarityPercent());
}
}
/** RGB file comparison ignoring alpha channel. */
public static void compareFilesUsingRgb()
{
String outputPath = "C:/images/output.png";
String referencePath = "C:/images/reference.png";
RgbComparerOptions options = new RgbComparerOptions();
options.setMaxChannelDifference((byte) 5);
options.setIgnoreAlpha(true);
IImageComparerResult result = ImageComparer.compare(outputPath, referencePath, options);
System.out.printf("RGB similarity (alpha ignored): %.2f%%\n",
result.getSimilarityPercent());
}
/** NCC comparison of image streams. */
public static void compareStreamsUsingNcc() throws IOException {
try (FileInputStream output = new FileInputStream("C:/images/output.png");
FileInputStream reference = new FileInputStream("C:/images/reference.png")) {
IImageComparerResult result = ImageComparer.compare(
output,
reference,
new NccComparerOptions());
System.out.printf("NCC similarity from streams: %.2f%%\n",
result.getSimilarityPercent());
}
}
/** Binary stream comparison. */
public static void compareStreamsBinary() throws IOException {
try (FileInputStream output = new FileInputStream("C:/images/output.png");
FileInputStream reference = new FileInputStream("C:/images/reference.png")) {
BinaryComparerOptions options = new BinaryComparerOptions();
options.setMaxDifferencePercent((double) 0);
IImageComparerResult result = ImageComparer.compare(output, reference, options);
System.out.printf("Binary similarity: %.2f%%\n",
result.getSimilarityPercent());
}
}
/** NCC comparison of loaded raster images. */
public static void compareRasterImagesUsingNcc()
{
try (RasterImage output = (RasterImage) Image.load("C:/images/output.png");
RasterImage reference = (RasterImage) Image.load("C:/images/reference.png")) {
IImageComparerResult result = ImageComparer.compare(
output,
reference,
new NccComparerOptions());
System.out.printf("NCC similarity: %.2f%%\n",
result.getSimilarityPercent());
}
}
/** Difference mask from file paths. */
public static void saveDifferenceMaskFromFiles()
{
String outputPath = "C:/images/output.png";
String referencePath = "C:/images/reference.png";
String maskPath = "C:/images/difference.png";
try (RasterImage mask = ImageComparer.createDifferenceMask(outputPath, referencePath)) {
mask.save(maskPath);
}
}
/** Difference mask from loaded raster images. */
public static void createDifferenceMaskFromRasterImages()
{
try (RasterImage output = (RasterImage) Image.load("C:/images/output.png");
RasterImage reference = (RasterImage) Image.load("C:/images/reference.png");
RasterImage mask = ImageComparer.createDifferenceMask(output, reference)) {
mask.save("C:/images/difference.png");
}
}
/** Difference mask from image streams. */
public static void saveDifferenceMaskFromStreams() throws IOException {
try (FileInputStream output = new FileInputStream("C:/images/output.png");
FileInputStream reference = new FileInputStream("C:/images/reference.png");
RasterImage mask = ImageComparer.createDifferenceMask(output, reference)) {
mask.save("C:/images/difference.png");
}
}
}
{IMAGINGJAVA-9342 Fix crop defects on AVIF image export
The exported image should have no significant defects.
try (AvifImage image = (AvifImage)Image.load(inputPath))
{
image.save(outputPath, new PngOptions());
}
{IMAGINGJAVA-9341 EMF to SVG: Output file is not rendered correctly
String folder = "D:/example";
for (int i = 1; i <= 14; i++)
{
String input = folder + "/image"+i+".emf";
String output = folder + "/image"+i+"_converted.svg";
try (Image imageVector = Image.load(input))
{
imageVector.save(output);
System.out.format("Converted: %s -> %s\n", input, output);
}
}
{IMAGINGJAVA-9338 Add deferred operations pipeline class
### Example
Two blending operations are queued and then applied to the target image.
String backgroundFilePath = "background.png";
String firstOverlayFilePath = "overlay-1.png";
String secondOverlayFilePath = "overlay-2.png";
String outputFilePath = "pipeline-result.png";
try (
RasterImage background = (RasterImage)Image.load(backgroundFilePath);
RasterImage firstOverlay = (RasterImage)Image.load(firstOverlayFilePath);
RasterImage secondOverlay = (RasterImage)Image.load(secondOverlayFilePath)
)
{
ImagePipeline pipeline = new ImagePipeline();
pipeline.blend(background, firstOverlay, new Point(0, 0));
pipeline.blend(
background,
secondOverlay,
BlendingMode.SCREEN,
new Point(100, 0));
// The target image is not changed before this call.
pipeline.applyPendingChanges();
background.save(outputFilePath);
}
{IMAGINGJAVA-9337 Support PS blending modes in image blending process
### Example
The overlay image is blended with the background using the Multiply mode.
String backgroundFilePath = "background.png";
String overlayFilePath = "overlay.png";
String outputFilePath = "multiply-result.png";
try (
RasterImage background = (RasterImage)Image.load(backgroundFilePath);
RasterImage overlay = (RasterImage)Image.load(overlayFilePath)
)
{
ImagePipeline pipeline = new ImagePipeline();
pipeline.blend(
background,
overlay,
BlendingMode.MULTIPLY,
new Point(50, 50),
(byte)192);
pipeline.applyPendingChanges();
background.save(outputFilePath);
}
{