Extract Images from PowerPoint PPT in C#

Extract Images from PowerPoint PPT in C#

While processing the PowerPoint presentations in a .NET application, you may need to extract content from the PPT slides. The content could be in the form of text and images. In the previous post, we have covered text extraction from PowerPoint slides. In this article, we will show you how to extract images from PowerPoint PPT or PPTX in C#.

C# .NET API to Extract Images from PowerPoint PPT

For extracting images from PowerPoint PPT/PPTX, we will use Aspose.Slides for .NET. It is a feature-rich .NET API that allows you to create new presentations and manipulate the existing ones seamlessly. You can either download API’s DLL or install it using NuGet.

PM> Install-Package Aspose.Slides.NET

Extract Images from a PowerPoint PPT in C#

The following are the steps to extract all the images in a PPT presentation in C#.

  • First, use Presentation class to load the PPT/PPTX file.
  • Then, loop through all the images in the presentation using Presentation.Images collection.
  • Finally, get type and format of each image and save it.

The following code sample shows how to extract images from a PowerPoint PPT in C#.

Extract Images from Shapes in a PPT

In various cases, you may need to extract images from the shape objects only. This can be achieved by following the steps below.

The following code sample shows how to extract images from shapes in a PPT using C#.

Extract Images from Slide Backgrounds in C#

Another possible scenario could be extracting images that are used only as slide backgrounds. The following steps show how to extract slide background images in C#.

The following code sample shows how to extract images from slide backgrounds in a PPT in C#.

We have used the method GetImageFormat in all of the above code snippets. This method returns the appropriate image format for the provided type. The implementation of this method is given below.

Get a Free License

You can get a free temporary license to use Aspose.Slides for .NET without evaluation limitations.

Conclusion

In this article, you have learned how to extract images from PowerPoint PPT/PPTX in C#. With the help of code samples, we have demonstrated how to extract images from shapes and slide backgrounds. You can explore more about Aspose.Slides for .NET by visiting the documentation. Also, you can ask your questions via our forum.

See Also