Browse our Products

Aspose.Imaging for .NET 17.01 - Release notes

Aspose.Imaging for .Net has been updated to version 17.01 and we are pleased to announce it. The following is a list of changes in this version of Aspose.Imaging.

Features and Improvements

KeySummaryCategory
IMAGINGNET-2002Unable to add layers to PSD fileEnhancement
IMAGINGNET-2132Implement JPEG lossless decoderEnhancement
IMAGINGNET-2206Converting PSD layer to PNG have lager font size then a PNG saved through Photoshop natively .NetEnhancement
IMAGINGNET-2207Updating text layer with many more characters than the source is showing incorrect results .NetEnhancement
IMAGINGNET-2208Updating text layer with non-English characters using Aspose, the characters are replaced by box .NetEnhancement

Usage examples

IMAGINGNET-2002 Unable to add layers to PSD file

 string sourceFileName = @"layerGroup.psd";

using (PsdImage image = (PsdImage)Aspose.Imaging.Image.Load(sourceFileName))

{

      LayerGroup layerGroup = image.AddLayerGroup("Test", 1, true);

      Rectangle rect = new Rectangle(0, 0, 100, 100);

      byte[] bytesR = new byte[rect.Width * rect.Height];

      byte[] bytesG = new byte[rect.Width * rect.Height];

      byte[] bytesB = new byte[rect.Width * rect.Height];

      for (int x = 0; x < rect.Width * rect.Height; x++)

      {

          bytesR[x] = (byte)(0 & 0xFF);

          bytesG[x] = (byte)(0 & 0xFF);

          bytesB[x] = (byte)(0 & 0xFF);

      }

      Layer layer = new Layer(rect, bytesR, bytesG, bytesB, "layer in group 1");

      layerGroup.AddLayer(layer);

      Layer[] layers = new Layer[image.Layers.Length - 1];

      for (int i = 0; i < layers.Length; i++)

      {

          layers[i] = image.Layers[i];

      }

      Layer l = image.Layers[8];

      image.Layers = layers;

      layerGroup.AddLayer(l);

      image.Save("result.psd");

}
 string sourceFileName = @"layerWithRectangle.psd";

using (PsdImage image = (PsdImage)Aspose.Imaging.Image.Load(sourceFileName))

{

    LayerMaskData mask = new LayerMaskDataShort();

    mask.Left = 100;

    mask.Top = 53;

    mask.Right = mask.Left + 50;

    mask.Bottom = mask.Top + 50;

    byte[] maskData = new byte[(mask.Right - mask.Left) * (mask.Bottom - mask.Top)];

    for (int i = 0; i < maskData.Length; i++)

    {

        maskData[i] = 255;

    }

    mask.ImageData = maskData;

    image.Layers[1].AddLayerMask(mask);

    image.Save(this.GetFileInOutputFolder("result.psd"));

}

IMAGINGNET-2132 Implement JPEG lossless decoder

 string srcImagePath = "Example_Encoding.bmp";

string dstImagePath = "Example_Encoding.jpg";

using (Aspose.Imaging.FileFormats.Bmp.BmpImage image = new Aspose.Imaging.FileFormats.Bmp.BmpImage(srcImagePath))

{

	JpegOptions options = new JpegOptions();

	options.CompressionType = JpegCompressionMode.Lossless;

	options.ColorType = JpegCompressionColorMode.Rgb;

	image.Save(dstImagePath, options);

}
 string srcImagePath = "Example_Decoding.jpg";

string dstImagePath = "Example_Decoding.bmp";

using (JpegImage image = new JpegImage(srcImagePath))

{

	image.Save(dstImagePath, new BmpOptions());

}

IMAGINGNET-2206 Converting PSD layer to PNG have lager font size then a PNG saved through Photoshop natively .Net

Not need to use option RemoveGlobalTextEngineResource when saving PSD image.

 string sourceFileName = "textRaster.psd";

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

{

    PsdImage psdImage = (PsdImage)image;

    for (int i = 0; i < psdImage.Layers.Length; i++)

    {

        if (psdImage.Layers[i] is TextLayer)

        {

            TextLayer aLayer = (TextLayer)psdImage.Layers[i];

            aLayer.UpdateText(@"Test text", 24.0f, Color.Black);

        }

    }

    psdImage.Save("result.psd",

                        new PsdOptions()

                        {

                            CompressionMethod = CompressionMethod.RLE

                        });

}

Not need to use option RemoveGlobalTextEngineResource when saving PSD image.

 string sourceFileName = @"textRaster.psd";

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

{

    PsdImage psdImage = (PsdImage)image;

    for (int i = 0; i < psdImage.Layers.Length; i++)

    {

        if (psdImage.Layers[i] is TextLayer)

        {

            TextLayer aLayer = (TextLayer)psdImage.Layers[i];

            PngOptions pngOptions = new PngOptions(){ ColorType = PngColorType.TruecolorWithAlpha };

            aLayer.Save(string.Format(@"textRasterLayer{0}.png", i), pngOptions);

        }

    }

}

IMAGINGNET-2207 Updating text layer with many more characters than the source is showing incorrect results .Net

 string sourceFileName = "overflowOK.psd";

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

{

  [PsdImage] psdImage = ([PsdImage])image;

  for (int i = 0; i < psdImage.Layers.Length; i++)

  {

        if (psdImage.Layers[i] is [TextLayer])

        {

            TextLayer aLayer = (TextLayer)psdImage.Layers[i];

            aLayer.UpdateText(@"Eu estou dirigindo para o otel.");

        }

  }

  psdImage.Save("result.psd",

              new [PsdOptions]()

              {

                            CompressionMethod = CompressionMethod.RLE

              });

}

IMAGINGNET-2208 Updating text layer with non-English characters using Aspose, the characters are replaced by box .Net

 string sourceFileName = "questionsandboxesWork.psd";

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

{

  PsdImage psdImage = (PsdImage)image;

  for (int i = 0; i < psdImage.Layers.Length; i++)

  {

    if (psdImage.Layers[i] is TextLayer){

        TextLayer aLayer = (TextLayer)psdImage.Layers[i];

        aLayer.UpdateText(@"Je suis au volant à l'hôtel.");

    }

  }

  psdImage.Save("result.psd",

              new PsdOptions()

              {

                  CompressionMethod = CompressionMethod.RLE

              });

}