Aspose.Imaging for .NET 22.8 - Release notes

Competitive features:

  • Implement Jpeg saved quality estimation
  • Review error messages in the entire library
KeySummaryCategory
IMAGINGNET-5477Implement Jpeg saved quality estimationFeature
IMAGINGNET-5447Review error messages in the entire libraryFeature
IMAGINGNET-5471Cannot export particular EPS imageEnhancement
IMAGINGNET-5453Incorrect saving Dicom imageEnhancement
IMAGINGNET-5450Incorrect extracting embedded bmp from Cdr imageEnhancement
IMAGINGNET-5394Incorrect export BMP -> JPG -> PNGEnhancement
IMAGINGNET-5369Problem in EMF to SVG conversionEnhancement
IMAGINGNET-5337Can’t load PNG imageEnhancement
IMAGINGNET-5255Artifacts appear when load tiff file and save to tiff with parametersEnhancement
IMAGINGNET-4937Can’t convert WMZ to PNGEnhancement
IMAGINGNET-4636SVG image Load method throws an exceptionEnhancement

Public API changes:

Added APIs:

Method Aspose.Imaging.Point.FromLong(System.Int64,System.Int32@,System.Int32@)

Method Aspose.Imaging.Point.ToLong

Removed APIs:

Usage Examples:

IMAGINGNET-5477 Implement Jpeg saved quality estimation

using (JpegImage image = (JpegImage)Image.Load("cat.jpg"))
{
    bool isNotDefaultQuality = image.JpegOptions.Quality != 75;
}

IMAGINGNET-5471 Cannot export particular EPS image

using var image = Image.Load("test.eps");
image.Save("output.png", new PngOptions());

IMAGINGNET-5453 Incorrect saving Dicom image

using (DicomImage image = (DicomImage)Image.Load("IMG-0002-00007.dcm"))
{
    image.Save("IMG-0002-00007.dcm.dcm");
}

IMAGINGNET-5450 Incorrect extracting embedded bmp from Cdr image

using (Image image = Image.Load(Path.Combine(@"D:\", "test.cdr")))
{
    var bmp_image = ((VectorImage)image).GetEmbeddedImages();
    var i = 0;
    foreach (var im in bmp_image)
    {
        using (im)
        {
            im.Image.Save(string.Format(@"D:\Cdr_image{0}.bmp", i++));
        }
    }
}

IMAGINGNET-5447 Review error messages in the entire library

Proper exception message example:

try
{
    // invalid CDR with no pages
    using (var image = Image.Load("city-auto-skf_2.cdr"))
    {

    }
}
catch (Exception e)
{
    var correctMessage = "CDR document contains no pages.";
    if (e.InnerException.Message != correctMessage)
    {
        throw;
    }
}

IMAGINGNET-5394 Incorrect export BMP -> JPG -> PNG

Correct BMP -> JPEG -> PNG export example:

using (var bmp = Image.Load("bmp-image.bmp"))
{
    using (var jpegStream = new MemoryStream())
    {
        bmp.Save(jpegStream, new JpegOptions { ColorType = JpegCompressionColorMode.Rgb });

        jpegStream.Position = 0;

        using (var jpeg = Image.Load(jpegStream))
        {
            jpeg.Save("bmp-to-jpeg-to-png.png", new PngOptions
            {
                ColorType = PngColorType.TruecolorWithAlpha,
                Progressive = true,
            });
        }
    }
}

IMAGINGNET-5369 Problem in EMF to SVG conversion

string baseFolder = @"D:\";
string file = "J_ORD042-I_0011.emf";
string inputFileName = Path.Combine(baseFolder, file);
string outputFileName = inputFileName + ".svg";
using (var image = Image.Load(inputFileName))
{
    image.Save(outputFileName, new SvgOptions());
}

IMAGINGNET-5337 Can’t load PNG image

Corrupted APNG loading in recovery mode and saving:

using (var image = Image.Load("input.png", new LoadOptions { DataRecoveryMode = DataRecoveryMode.ConsistentRecover }))
{
    image.Save("output.png");
}

IMAGINGNET-5255 Artifacts appear when load tiff file and save to tiff with parameters

Attached TIFF sample loading and export example:

using (var image = Image.Load("input.tiff") as RasterImage)
{
    var xmp = image.XmpData;

    if (xmp == null)
    {
        var xmpHeader = new XmpHeaderPi(Guid.NewGuid().ToString());
        var xmpTrailer = new XmpTrailerPi(true);
        var xmpMeta = new XmpMeta();

        xmp = new XmpPacketWrapper(xmpHeader, xmpTrailer, xmpMeta);

        image.XmpData = xmp;
    }

    if (xmp.ContainsPackage("dc"))
    {
        foreach (var xmpPackage in xmp.Packages)
        {
            if (xmpPackage.NamespaceUri.Trim().ToLower() == "http://purl.org/dc/elements/1.1/")
            {
                if (xmpPackage.ContainsKey("dc:keywords"))
                {
                    xmpPackage["dc:keywords"] = "2021";
                }
                else
                {
                    xmpPackage.AddValue("dc:keywords", "2021");
                }
            }
        }
    }
    else
    {
        var xmpPackage = new XmpBasicPackage("dc", "http://purl.org/dc/elements/1.1/");
        xmpPackage.AddValue("dc:keywords", "2021");
        xmp.AddPackage(xmpPackage);
    }

   image.Save("output.tiff", new TiffOptions(TiffExpectedFormat.TiffLzwRgba));
}

IMAGINGNET-4937 Can’t convert WMZ to PNG

Now WMZ export to raster PNG format works properly:

using (var image = Image.Load("image.wmz"))
{
    var options = new PngOptions
    {
        VectorRasterizationOptions = new WmfRasterizationOptions()
        {
            PageHeight = image.Height,
            PageWidth = image.Width
        }
    };

    image.Save("result.png", options);
}

IMAGINGNET-4636 SVG image Load method throws an exception

SVG loading and export example:

using (var image = Image.Load("input.svg"))
{
    image.Save("svg-to-png.png", new PngOptions());
}