How to Extract Images from a PowerPoint Document

Here is a nice PowerPoint document with lot of images embedded in the slides .Is there any easy method to save them out of the presentation through C# or VB.NET? The answer is positive. This article will present a quick solution to extract images from a PowerPoint document automatically and programmatically by using Spire.Presentation for .NET.

Firstly, you need to prepare your environment (WinForms, ASP.NET, Windows Service) and associate your project with Spire.Presentation.Dll .Then, follow the code snippet in C# to extract every image embedded in the PPT file and save it to the local folder.

Step 1: Create an instance of presentation class and load PowerPoint document from disk

Presentation ppt = new Presentation();
ppt.LoadFromFile(@"C:\Work\MyPPT\test.ppt");

Step 2: Traversal all images in PowerPoint document and save them as .png to the local folder

for (int i = 0; i < ppt.Images.Count; i++)
{
Image image = ppt.Images[i].Image;
image.Save(string.Format(@"C:\Work\MyPPT\Images{0}.png", i));

}

PowerPoint file that contains fantastic images:

Extract Images from a PowerPoint Document

Result:

Extract Images from a PowerPoint Document

Full code:

[C#]
Presentation ppt = new Presentation();
ppt.LoadFromFile(@"..\..\test.pptx");
for (int i = 0; i < ppt.Images.Count; i++)
{
Image image = ppt.Images[i].Image;
image.Save(string.Format(@"..\..\Images{0}.png", i));

}
[VB.NET]
Dim ppt As New Presentation()
ppt.LoadFromFile("..\..\test.pptx")

For i As Integer = 0 To ppt.Images.Count - 1
 Dim image As Image = ppt.Images(i).Image
image.Save(String.Format("..\..\Images{0}.png", i))
Next