DEV Community

Dmitry Matuzko
Dmitry Matuzko

Posted on • Updated on

Interesting features of Aspose.Imaging

Hello, in this article I'm going to list what distinguishes Aspose.Imaging from other similar software and generally about it's interesting features.

Unified API for .Net above 2.0 and Java

Aspose.Imaging is built for .Net and Java from single source and hence both versions are identical and have the same API. The documentation for API is availible for both versions at and is styled according to convention of .Net and Java ecosystems respectively. There's no difference other than styling. Note that in this and other articles I refer to .Net version of docs.

Cloud version via REST API

There is a public REST API service that allows you to use Aspose.Imaging, upload files to the API host, process them and download them back. See documentation at Aspose.Imaging Cloud Documentation.

ICC color profile support

Aspose.Imaging can convert images using the a specified color profile. Color profiles are supported for TIFF, PSD and JPEG images (when YCCK or CMYK color mode is used). an example on using color profiles for TIFF images cam be found in the Converting RGB TIFF to CMYK TIFF with Aspose.Imaging 18.3 article.

Grayscale ICC profile support

Grayscale ICC profile can be accessed via GrayColorProfile property of PsdImage. See the example:

    using (PsdImage psdImage = (PsdImage)Image.Load("gray-d15.psd"))
        //StreamSource cmykProfile = psdImage.CmykColorProfile;
        //StreamSource rgbProfile = psdImage.RgbColorProfile;
        StreamSource grayProfile = psdImage.GrayColorProfile;

        // Save to grayscale TIFF
        TiffOptions saveOptions = new TiffOptions(TiffExpectedFormat.Default);
        saveOptions.Photometric = TiffPhotometrics.MinIsBlack;
        saveOptions.BitsPerSample = new ushort[] { 8 };

        // No ICC profile
        psdImage.Save("gray-d15.psd.noprofile.tif", saveOptions);

        // Embed ICC profile
        saveOptions.IccProfile = ToMemoryStream(grayProfile);
        psdImage.Save("gray-d15.psd.tif", saveOptions);
Enter fullscreen mode Exit fullscreen mode

Multithreading support.

All images loaded by Aspose.Imaging are independent instances and can be processed concurrently without problems. Though, manipulation with a single image should happen only within one thread.

OpenDocument Graphics (ODG) support

Aspose.Imaging can load ODG images and export them to raster. As with any other readable format, these files are loaded with Image.Load() method.

Rasterization of SVG and Metafile (EMF, WMF) vector images

These formats can as well be loaded by Image.Load() method and then saved to any supported export format.

public void SvgToPng()
    string path = "in.svg";
    string destFilePath = "out.png";
    using (Image image = Image.Load(path))
        image.Save(destFilePath, new PngOptions());
Enter fullscreen mode Exit fullscreen mode

DICOM and DJVU support

These are supported as import formats, Aspose.Imaging cannot export them yet. Multipage support works for both formats, and you can select which pages you want to export. The detailed examples are provided in Introduction to Aspose.Imaging, Part 2 article.

Saving images to PDF format.

Loaded images can be exported to PDF. Note that only output of PDF files is supported, Aspose.Imaging doesn't read them, that's the job of another product, Aspose.PDF. As any export, it can be selected by creating PdfOptions instance and passing it to Image.Save(). Here's the example:

public void GifToPdf()
    string path = "transparent_orig.gif";
    string destFilePath = "transparent_orig.gif.pdf";
    using (Image image = Image.Load(path))
        image.Save(destFilePath, new PdfOptions());
Enter fullscreen mode Exit fullscreen mode

XMP and EXIF metadata support.

Both metadata formats can be read and manipulated with Aspose.Imaging.
See example for using XMP metadata in Introduction to Aspose.Imaging, Part 5 article.

Large image support

Aspose.Imaging supports working on images that do not fit into RAM, allowing you to process very large image files even on relatively weak computers.

16 bit per channel TIFF support

Since version 18.6, Aspose.Imaging supports TIFF files with 16 bit channels. However, support is not complete yet, ICC profiles are not applied currently. There is an example on how to extract per-channel values:

// ICC profile is not applied for 16-bit color components at the moment, so disable that option explicitly.
LoadOptions loadOptions = new LoadOptions();
loadOptions.UseIccProfileConversion = false;

Rectangle desiredArea = new Rectangle(470, 1350, 30, 30);

using (RasterImage image = (RasterImage)Image.Load(tiff16File, loadOptions))
    long[] colors64Bit = image.LoadArgb64Pixels(image.Bounds);

    ushort alpha, red, green, blue;
    for (int y = desiredArea.Top; y < desiredArea.Bottom; ++y)
        for (int x = desiredArea.Left; x < desiredArea.Right; ++x)
            int offset = y * image.Width + x;
            long color64 = colors64Bit[offset];

            alpha = (ushort)((color64 >> 48) & 0xffff);
            red = (ushort)((color64 >> 32) & 0xffff);
            green = (ushort)((color64 >> 16) & 0xffff);
            blue = (ushort)(color64 & 0xffff);

            Console.WriteLine("A={0}, R={1}, G={2}, B={3}", alpha, red, green, blue);
Enter fullscreen mode Exit fullscreen mode

DNG support

DNG file format can be read by Aspose.Imaging for lossless processing of photo images. As with any other images, just call Image.Load().

Lossless JPEG and JPEG-LS support

These are rarely implemented compression method for JPEG files. Aspose.Imaging allows setting compression type via CompressionType property of JpegOptions. Also, baseline and progressive compression methods are supported.

Jpeg2000 support.

This is also a rarely supported format. Aspose.Imaging supports both import and export of Jpeg2000 images. As any other output format, it can be selected for export by creating Jpeg2000Options instance and passing it to Image.Save() method.

Support of exporting EMF images

EMF images can be exported by Aspose.Imaging. See example on how to work with them:

public void TestSaveEmf()
    var path = @"TestEmfBezier.emf";
    using (var image = (MetaImage)Image.Load(path))
        image.Save(path + ".emf", new EmfOptions());

public void TestSaveEmfPlus()
    var path = @"TestEmfPlusFigures.emf";
    using (var image = (MetaImage)Image.Load(path))
        image.Save(path + ".emf", new EmfOptions());

public void TestSaveEmfGraphics()
    EmfRecorderGraphics2D graphics = new EmfRecorderGraphics2D(
        new Rectangle(0, 0, 5000, 5000),
        new Size(5000, 5000),
        new Size(1000, 1000));
        Font font = new Font("Arial", 10, FontStyle.Bold | FontStyle.Underline);
        graphics.DrawString(font.Name + " " + font.Size + " " + font.Style.ToString(), font, Color.Brown, 10, 10);
        graphics.DrawString("some text", font, Color.Brown, 10, 30);

        font = new Font("Arial", 24, FontStyle.Italic | FontStyle.Strikeout);
        graphics.DrawString(font.Name + " " + font.Size + " " + font.Style.ToString(), font, Color.Brown, 20, 50);
        graphics.DrawString("some text", font, Color.Brown, 20, 80);

        using (EmfImage image = graphics.EndRecording())
            var path = @"Fonts.emf";
            image.Save(path, new EmfOptions());
Enter fullscreen mode Exit fullscreen mode

Specific image format support optimisations

Aspose.Imaging supports lossy GIF for reducing GIF image size.
For JPEG, rate-distortion optimisation is used to optimise image quality during compression.

Coming soon

.Net Standard

.Net Standard will be supported in the near future, so there will be a version of the library with native .NET Core support.

Reverse image search

Aspose.Imaging for Cloud (i.e. the public REST API) will support reverse image search soon!

Phasing out

PSD support

PSD support will be moved to its own product, Aspose.PSD.

For now, that's all. This article will be updated with new and old interesting features in the future.

Top comments (0)