Browse our Products

Aspose.Imaging for .NET 18.8 - Release Notes

KeySummaryCategory
IMAGINGNET-3007How to change window size s in BinarizeBradley methodFeature
IMAGINGNET-3059Improve JPEG DCT decoder performance.Enhancement
IMAGINGNET-3055Incorrect creation of graphic objects EmfRecorderGraphics2DEnhancement
IMAGINGNET-3052Updating text layer for PSD image throws error when opened in PhotoshopEnhancement
IMAGINGNET-3050Add watermark for export to EMF/EMF+ without a licenseEnhancement
IMAGINGNET-3048EMF file not properly converted to SVGEnhancement
IMAGINGNET-3047EMF to SVG not properly convertedEnhancement
IMAGINGNET-3046Color radiance issues in imagesEnhancement
IMAGINGNET-3045Temp files are created when saving DJVU documentsEnhancement
IMAGINGNET-3008PsdImageException thrown on updating PSD textEnhancement
IMAGINGNET-2993Low quality JPEG generatedEnhancement
IMAGINGNET-2991ImageSave exception on saving JPEG to PNG or PDFEnhancement
IMAGINGNET-2983Empty results when converting Eps to Raster on Compact and non license/venture modeEnhancement
IMAGINGNET-2883CropBmpMultithreading() produces blank Bmp imagesEnhancement

Public API changes:

Added APIs:

Class Aspose.Imaging.FileFormats.Emf.EmfRenderMode

Field/Enum Aspose.Imaging.FileFormats.Emf.EmfRenderMode.Auto

Field/Enum Aspose.Imaging.FileFormats.Emf.EmfRenderMode.Dual

Field/Enum Aspose.Imaging.FileFormats.Emf.EmfRenderMode.EmfOnly

Field/Enum Aspose.Imaging.FileFormats.Emf.EmfRenderMode.EmfPlusOnly

Method Aspose.Imaging.FileFormats.Dicom.DicomImage.BinarizeBradley(System.Double,System.Int32)

Method Aspose.Imaging.FileFormats.Djvu.DjvuImage.BinarizeBradley(System.Double,System.Int32)

Method Aspose.Imaging.FileFormats.Eps.EpsImage.Save(System.IO.Stream,Aspose.Imaging.ImageOptionsBase,Aspose.Imaging.Rectangle)

Method Aspose.Imaging.FileFormats.Psd.PsdImage.BinarizeBradley(System.Double,System.Int32)

Method Aspose.Imaging.FileFormats.Tiff.TiffImage.BinarizeBradley(System.Double,System.Int32)

Method Aspose.Imaging.FileFormats.Webp.WebPImage.BinarizeBradley(System.Double,System.Int32)

Method Aspose.Imaging.RasterCachedImage.BinarizeBradley(System.Double,System.Int32)

Method Aspose.Imaging.RasterImage.BinarizeBradley(System.Double,System.Int32)

Property Aspose.Imaging.ImageOptions.EmfRasterizationOptions.RenderMode

Removed APIs:

Property Aspose.Imaging.FileFormats.Djvu.DjvuImage.Location

Property Aspose.Imaging.FileFormats.Djvu.DjvuImage.Name

Usage examples:

IMAGINGNET-3007 How to change window size s in BinarizeBradley method

 string sourceFile = @"test.png";

string outputFile = "result.png";

using (PngImage image = (PngImage)Image.Load(sourceFile))

{

    image.BinarizeBradley(10, 20);

    image.Save(outputFile);

}

IMAGINGNET-3059 Improve Jpeg DCT decoder performance.

Please use the following code to compare the running time of the optimized and non-optimized version:

 public static void TestJira3059_Example()

{

	string dir = @"c:\aspose.work\IMAGINGNET\3059\";

	System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

	sw.Start();

	Resize_Aspose(dir + "interleaved.jpg", dir + "interleaved.out.jpg", 300, 300);

	sw.Stop();

	long msInterleaved = sw.ElapsedMilliseconds;

	sw.Reset();

	sw.Start();

	Resize_Aspose(dir + "non-interleaved.jpg", dir + "non-interleaved.out.jpg", 300, 300);

	sw.Stop();

	long msNonInterleaved = sw.ElapsedMilliseconds;

	Console.WriteLine("**** Conversion {0} takes {1} ms.", "interleaved.jpg", msInterleaved);

	Console.WriteLine("**** Conversion {0} takes {1} ms.", "non-interleaved.jpg", msNonInterleaved);

}

/// <summary>

/// Loads image, resizes and then saves it using Aspose.Imaging.

/// </summary>

/// <param name="inputPath">The input file path.</param>

/// <param name="outputPath">The output file generated with Aspose.Imaging.</param>

/// <param name="desiredWidth">The desired width of the resized image.</param>

/// <param name="desiredHeight">The desired height of the resized image.</param>

private static void Resize_Aspose(string inputPath, string outputPath, int desiredWidth, int desiredHeight)

{

	using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputPath))

	{

		int originalWidth = image.Width;

		int originalHeight = image.Height;

		float percentWidth = (float)desiredWidth / (float)originalWidth;

		float percentHeight = (float)desiredHeight / (float)originalHeight;

		float percent = percentHeight < percentWidth ? percentHeight : percentWidth;

		int newWidth = Math.Min((int)(originalWidth * percent), originalWidth);

		int newHeight = Math.Min((int)(originalHeight * percent), originalHeight);

		image.Resize(newWidth, newHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);

		image.Save(outputPath);

	}

}

We have got the following result: v18.7 Conversion interleaved.jpg takes 3656 ms. Conversion non-interleaved.jpg takes 1489 ms.

Optimized Conversion interleaved.jpg takes 1966 ms. Conversion non-interleaved.jpg takes 809 ms.

IMAGINGNET-3055 Incorrect creation of graphic objects EmfRecorderGraphics2D

 EmfRecorderGraphics2D graphics = new EmfRecorderGraphics2D(

    new Rectangle(0, 0, 1000, 1000), new Size(1000, 1000),

    new Size(100, 100));

Pen pen = new Pen(Color.Red);  // RED color

graphics.DrawLine(pen, 1, 1, 50, 50);

using (EmfImage image = graphics.EndRecording())

{

    image.Save("test_pen.emf", new EmfOptions());

}

IMAGINGNET-3052 Updating text layer for PSD image throws error when opened in Photoshop

 string filePath = @"test.psd";            

            string outputFilePath = "result.psd";

            using (Image image = Image.Load(filePath))

            {

                if (!(image is PsdImage))

                {

                    return;

                }

                PsdImage psdImage = (PsdImage)image;

                Layer[] layers = psdImage.Layers;

                for (int index = layers.Length - 1; index >= 0; index--)

                {

                    Layer layer = layers[index];

                    if (!(layer is TextLayer))

                    {

                        continue;

                    }

                    TextLayer textLayer = (TextLayer)layer;

                    textLayer.UpdateText(@"\\()");

                }

                PsdOptions imageOptions = new PsdOptions(psdImage);


                psdImage.Save(outputFilePath, imageOptions);

          }

IMAGINGNET-3050 Add watermark for export to EMF/EMF+ without a license

 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());

        }

    }

}

IMAGINGNET-3048 EMF file not properly converted to SVG

input file: image39.emf output file: image39.emf.svg

             string baseFolder = @"D:\";

            string fileName = "image39.emf";

            string inputFileName = Path.Combine(baseFolder, fileName);

            string outputFileName = Path.Combine(baseFolder, fileName+".svg");

            using (Image image = Image.Load(inputFileName))

            {

                EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions

                {

                    PageSize = image.Size

                };

                image.Save(outputFileName, new SvgOptions { VectorRasterizationOptions = emfRasterizationOptions });

            }

IMAGINGNET-3047 EMF to SVG not properly converted

This example demonstrates how to work with emf files contain emf+ records in different modes input file:image11.emf output files:image11_Auto.png, image11_Dual.png, image11_EmfOnly.png, image11_EmfPlusOnly.png

             string fileName = "image11.emf";

            string baseFolder = @"D:\";

            string inputFileName = Path.Combine(baseFolder, fileName);

            EmfRenderMode[] modes = new EmfRenderMode[]

            {

                EmfRenderMode.Auto, //default mode, render records auto

                EmfRenderMode.EmfOnly, // render only emf records

                EmfRenderMode.EmfPlusOnly, //render only emf+ records

                EmfRenderMode.Dual //render emf+ and emf records

            };

            foreach (EmfRenderMode mode in modes)

            {

                string outputFileName =Path.Combine(baseFolder, string.Format("{0}_{1}.png", Path.GetFileNameWithoutExtension(fileName), mode));

                using (Image image = Image.Load(inputFileName))

                {

                    EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions

                    {

                        PageSize = image.Size,

                        RenderMode = mode

                    };

                    PngOptions pngOptions = new PngOptions {VectorRasterizationOptions = emfRasterizationOptions};

                    image.Save(outputFileName, pngOptions);

                }

            }

This example for export to svg file

input file:image11.emf output file: image11.emf.svg

             string baseFolder = @"D:\";

            string fileName = "image11.emf";

            string inputFileName = Path.Combine(baseFolder, fileName);

            string outputFileName = Path.Combine(baseFolder, fileName + ".svg");

            using (Image image = Image.Load(inputFileName))

            {

                EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions

                {

                    PageSize = image.Size

                };

                image.Save(outputFileName, new SvgOptions { VectorRasterizationOptions = emfRasterizationOptions });

            }

IMAGINGNET-3045 Temp files are created when saving DJVU documents

 using (DjvuImage image = (DjvuImage)Image.Load("sample.djvu"))

{

     image.Save("sample.bmp", new BmpOptions());

}

IMAGINGNET-3008 PsdImageException thrown on updating PSD text

 string filePath = "arabic.psd";

string newText = "test";

string outputFilePath = "result.psd";

using (Image image = Image.Load(filePath))

{

     if (!(image is PsdImage))

     {

         return;

     }

     PsdImage psdImage = (PsdImage)image;

     Layer[] layers = psdImage.Layers;

     for (int index = layers.Length - 1; index >= 0; index--)

     {

         Layer layer = layers[index];

         if (!(layer is TextLayer))

         {

             continue;

         }

         TextLayer textLayer = (TextLayer)layer;

         textLayer.UpdateText(newText);

     }

     PsdOptions imageOptions = new PsdOptions(psdImage);

     psdImage.Save(outputFilePath, imageOptions);

}

IMAGINGNET-2993 Low quality JPEG generated

input file: aspose-logo.jpg output file: aspose-logo_Output.jpg

             string dataDir = @"D:\";

            string sourceFile = dataDir + @"aspose-logo.jpg";

            string destFileName = dataDir + @"aspose-logo_Output.jpg";

            using (RasterImage newImage = (RasterImage)Image.Load(sourceFile))

            {

                JpegOptions jpgCreateOptions = new ImageOptions.JpegOptions();

                jpgCreateOptions.Quality = 100;

                jpgCreateOptions.CompressionType = JpegCompressionMode.Progressive;

                jpgCreateOptions.Source = new Sources.FileCreateSource(destFileName, false);

                using (var JpgImage = (JpegImage)Image.Create(jpgCreateOptions, newImage.Width, newImage.Height))

                {                    

                    if (JpgImage.ExifData == null)

                    {

                        JpgImage.ExifData = new JpegExifData();

                    }

                    JpgImage.ExifData.ResolutionUnit = Exif.Enums.ExifUnit.Inch;

                    JpgImage.ExifData.XResolution = new TiffRational((uint)newImage.Width);

                    JpgImage.ExifData.YResolution = new TiffRational((uint)newImage.Height);

                    JpgImage.SavePixels(JpgImage.Bounds, newImage.LoadPixels(newImage.Bounds));

                    JpgImage.Save();

                }

            }

IMAGINGNET-2991 ImageSave exception on saving JPEG to PNG or PDF

 string outputFile = "result.png";

using (Image m_oDocument = Aspose.Imaging.Image.Load(("sample4_l.jpg")))

{

    int m_iPageCount = 1;

    //resize

    if (((Aspose.Imaging.Image)m_oDocument).Width > ((Aspose.Imaging.Image)m_oDocument).Height)

    {

        if (((Aspose.Imaging.Image)m_oDocument).Width > 1024)

        {

             int iWidth = 1024;

             int iHeight = (int) ((1024.0f / (float)((Aspose.Imaging.Image)m_oDocument).Width) * (float)((Aspose.Imaging.Image)m_oDocument).Height);

             ((Aspose.Imaging.Image)m_oDocument).Resize(

             iWidth,

             iHeight,

             Aspose.Imaging.ResizeType.NearestNeighbourResample);

        }

     }

     else

     {

         if (((Aspose.Imaging.Image)m_oDocument).Height > 1024)

         {

             int iHeight = 1024;

             int iWidth = (int) ((1024.0f / (float)((Aspose.Imaging.Image)m_oDocument).Height) * (float)((Aspose.Imaging.Image)m_oDocument).Width);

             ((Aspose.Imaging.Image)m_oDocument).Resize(

                    iWidth,

                    iHeight,

                    Aspose.Imaging.ResizeType.NearestNeighbourResample);

         }

     }

     Aspose.Imaging.ImageOptions.PngOptions OptionsIM = new Aspose.Imaging.ImageOptions.PngOptions();

     OptionsIM.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;

     Aspose.Imaging.ResolutionSetting oResIM = new Aspose.Imaging.ResolutionSetting(

            Convert.ToDouble(120),

            Convert.ToDouble(120));

     OptionsIM.ResolutionSettings = oResIM;

     ((Aspose.Imaging.Image)m_oDocument).Save(outputFile, OptionsIM);

}

IMAGINGNET-3046 Color radiance issues in images

input file: image34.emf output file: image34.emf.svg

             string baseFolder = @"D:\";

            string fileName = "image34.emf";

            string inputFileName = Path.Combine(baseFolder, fileName);

            string outputFileName = Path.Combine(baseFolder, fileName + ".svg");

            using (Image image = Image.Load(inputFileName))

            {

                EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions

                {

                    PageSize = image.Size

                };

                image.Save(outputFileName, new SvgOptions() { VectorRasterizationOptions = emfRasterizationOptions });

            }