Extra Artifact Appears When Converting a Presentation Shape to an Image in C#

Hi Team,

I have attached a sample PPTX with a single slide containing a single shape. When I use Aspose to open this PPTX and try to get the image of this shape, I am getting extra artifact in the image. I have attached the output image too for your reference.

output.png (7.0 KB)

sample.zip (24.7 KB)

The code I used to get the image is given below:

using Aspose.Slides;
using Aspose.Slides.Export;
using System.Drawing.Imaging;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // Load the presentation
            using (Presentation presentation = new Presentation("sample.pptx"))
            {
                // Get the first slide as an image
//                using (var img = presentation.Slides[0].GetThumbnail(1, 1))
//                {
//                    // Save the image
//                    img.Save("output.png", System.Drawing.Imaging.ImageFormat.Png);
//                    Console.WriteLine("Image saved successfully as output.png");
//                }

                foreach (var curShape in presentation.Slides[0].Shapes)
                {
                    using (var curImage = curShape.GetImage())
                    {
                        // Save the image
                        curImage.Save("output.png", Aspose.Slides.ImageFormat.Png);
                        Console.WriteLine("Image saved successfully as output.png");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred: {ex.Message}");
        }
    }
}

Could you pls take a look at the output and help us resolve this issue. Thank you

Tested with Aspose 25.5 release.

@bhav

@bhav

It seems you are experiencing an issue with extra artifacts appearing in the image generated from a shape in your PPTX file using Aspose.Slides. This can sometimes occur due to how the shape is rendered or how the image is being processed.

To troubleshoot and potentially resolve this issue, you can try the following steps:

  1. Check Shape Properties: Ensure that the shape does not have any effects (like shadows or reflections) that might be causing artifacts when rendered as an image.

  2. Use GetThumbnail Method: Instead of using GetImage() for each shape, consider using the GetThumbnail method on the slide. This method generates a thumbnail of the entire slide, which might help in avoiding artifacts. Here’s a modified version of your code:

    using Aspose.Slides;
    using Aspose.Slides.Export;
    using System.Drawing.Imaging;
    
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // Load the presentation
                using (Presentation presentation = new Presentation("sample.pptx"))
                {
                    // Get the first slide as an image
                    using (var img = presentation.Slides[0].GetThumbnail(1, 1))
                    {
                        // Save the image
                        img.Save("output.png", ImageFormat.Png);
                        Console.WriteLine("Image saved successfully as output.png");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"An error occurred: {ex.Message}");
            }
        }
    }
    
  3. Update Aspose.Slides: Ensure you are using the latest version of Aspose.Slides, as updates often include bug fixes and improvements that could resolve rendering issues.

  4. Check for Known Issues: Review the Aspose.Slides documentation or forums for any known issues related to image rendering that might be similar to your case.

If the problem persists after trying these suggestions, consider sharing more details about the specific shape and its properties, or any additional context that might help in diagnosing the issue further.

Sources:
[1]: CreateShapeThumbnail.cs

@bhav,
Thank you for reporting on the issue. I’ve reproduced the problem with displaying the text when converting the shape to an image. We apologize for any inconvenience caused.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-44955

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thank you Andrey. Appreciate your responsiveness !

@bhav,
Thank you for helping make Aspose.Slides better.