Free Support Forum - aspose.com

Extract background image for PPTX with transparency

Hi Team,

Aspose Version: 20.1
Language: C#

I am looking to extract the background image applied on PPTX using below options
Add a background picture to slides - PowerPoint (microsoft.com)

Below is the code I am using. It does extract the original image but not the image with effects or styles applied to it. I have applied transparency on the image and want to get an image from Aspose API.
Output -> BackImage_Slide_Aspose.Slides.Slide.jpeg (359.6 KB)

PPTX ->sample.zip (400.3 KB)

	public static System.Drawing.Imaging.ImageFormat GetImageFormat(String ImageType)
	{
		System.Drawing.Imaging.ImageFormat Format = System.Drawing.Imaging.ImageFormat.Jpeg;
		switch (ImageType)
		{
			case "jpeg":
				Format = System.Drawing.Imaging.ImageFormat.Jpeg;
				break;

			case "emf":
				Format = System.Drawing.Imaging.ImageFormat.Emf;
				break;

			case "bmp":
				Format = System.Drawing.Imaging.ImageFormat.Bmp;
				break;

			case "png":
				Format = System.Drawing.Imaging.ImageFormat.Png;
				break;

			case "wmf":
				Format = System.Drawing.Imaging.ImageFormat.Wmf;
				break;

			case "gif":
				Format = System.Drawing.Imaging.ImageFormat.Gif;
				break;

		}
		return Format;


	}
	
			Presentation pres = new Presentation(m_szPptxPath);
			ISlide sl = pres.Slides[0];
			Aspose.Slides.IPPImage img = null;
			String ImageType = "";
			Aspose.Slides.IPPImage Backimg = null;
			System.Drawing.Imaging.ImageFormat Format = System.Drawing.Imaging.ImageFormat.Jpeg;
			if (sl.Background.FillFormat.FillType == FillType.Picture)
			{
				//Getting the back picture  
				Backimg = sl.Background.FillFormat.PictureFillFormat.Picture.Image;

				//Setting the desired picture format 

				ImageType = Backimg.ContentType;
				ImageType = ImageType.Remove(0, ImageType.IndexOf("/") + 1);
				Format = GetImageFormat(ImageType);

				String ImagePath = "./input/BackImage_";
				Backimg.SystemImage.Save(ImagePath + "Slide_" + sl.ToString() + "." + ImageType, ImageFormat.Jpeg);

			}

Is there any API for that?

Please share your thoughts.

Thanks
~ Praveen

Another finding,

It seems to retain other property like saturation

PPTX- sample.zip (4.3 MB)
Output - sample_slide_1.jpg (131.9 KB)

Saturation.png (30.9 KB)

Please share your thoughts. thanks

@pradubey,
Thank you for the issue description. I reproduced the problem and logged the issue in our tracking system with ID SLIDESNET-42587. Our development team will investigate this case. I will inform you about any progress.

Hi @Andrey_Potapov

Thanks,

Meanwhile, do you have an ETA and a suggested workaround to temporarily resolve this issue?

~ Praveen

@pradubey,
I requested some ETA for the issue from our development team. I will let you know as soon as possible. Unfortunately, I don’t see a workaround yet.

@pradubey,
Our development team suggests that you try the following workaround:

using (Presentation presSource = new Presentation("sample.pptx"),
       presTemp = new Presentation())
{
    ISlide backgroundSlide = presSource.Slides[0];

    ISlide clonedSlide = presTemp.Slides.AddClone(backgroundSlide, presTemp.Slides[0].LayoutSlide);
    clonedSlide.Shapes.Clear();

    clonedSlide.GetThumbnail(new Size(960, 720)).Save("bg.png", ImageFormat.Png);
}

Thanks Andrey. I will try this