The First Slide Displays for Longer When Generating a GIF from a PPTX File in C#

Hello,
I am generating a GIF with a PPTX file with a delay of 0.25s between each slide (using DefaultDelay = 250 from Aspose.Slides.Export.GifOptions), then I am saving it with Aspose.Imaging for my GIF to loop. But the 1st slide stays longer than the other on both gifs (with or without loop). It’s a problem for me. Do you have a solution?

Aspose.Slide.NET 25.10.0 and Aspose.Imaging.NET 25.10.0

In the attachment, the code and the document I’ve used for the test.
element.zip (337.5 KB)

Thank you, best regards.

@ISIWARE

It appears that the first slide in your generated GIF is displaying for a longer duration than the others, despite setting a delay of 0.25 seconds for each slide using DefaultDelay = 250 in Aspose.Slides.Export.GifOptions.

This issue may arise from how the GIF format manages the timing of the first frame. A common workaround is to explicitly set the delay for the first slide to match the others. You can achieve this by adjusting the Delay property for the first frame after creating the GIF.

Here’s a sample code snippet to help you set the delay for the first slide:

using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Imaging;

using (Presentation presentation = new Presentation("your_presentation.pptx"))
{
    GifOptions gifOptions = new GifOptions
    {
        DefaultDelay = 250 // Set delay to 250 ms
    };

    using (var gifStream = new MemoryStream())
    {
        presentation.Save(gifStream, SaveFormat.Gif, gifOptions);
        
        // Load the GIF to modify the first frame delay
        using (var gifImage = Image.Load(gifStream))
        {
            // Set the delay for the first frame
            gifImage.Frames[0].Delay = 250; // Ensure the first frame has the same delay
            gifImage.Save("output.gif");
        }
    }
}

Make sure to replace "your_presentation.pptx" with the path to your actual PPTX file. This adjustment should ensure that the first slide displays for the same duration as the others.

If the issue persists, consider consulting the Aspose forums or documentation for any updates or similar issues reported by other users.

@ISIWARE,
Thank you for contacting free support. I need some time to investigate the issue. I will get back to you as soon as possible.

@ISIWARE,
Thank you for your patience. I have reproduced the issue where the first slide displays for longer when converting the presentation to a GIF image.

It appears that the issue is caused by the transition duration being set to 3.90 seconds for the first slide; however, changing the duration for the first slide does not resolve the issue.

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-45152

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.