Free Support Forum - aspose.com

Grayscale ppt(slides) from a colored ppt(slides)..?

Hi,

we want to generate grayscale ppt from colored. Can I know is there any way supported by aspose through which we can generate grayscale ppt(slides) from a colored ppt(slides). Please suggested asap.

Dear Prafull_Gupta,

Yes, it is possible. I will see, if I could provide you example code, how to achieve it.

I have attached a VB.NET console application project. It reads the source presentation and converts into grayscale output presentation namely c:\outGray.ppt <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Basically, it gets the images of the slides from source presentation and then gray out those images and adds them in destination presentation.

You can also see the destination presentation in the attachment.

VB.NET CODE

Dim source As String = "..\..\..\source.ppt"

'Read the source presentation

Dim srcPres As New Presentation(source)

'Create the target presentation

Dim dstPres As New Presentation

'Get the default slide

Dim defaultSld As Slide = dstPres.GetSlideByPosition(1)

'Get the thumbnails of presentation

Dim lastSlidePos As Integer = srcPres.Slides.LastSlidePosition

For pos As Integer = 1 To lastSlidePos

Dim sld As Slide

sld = srcPres.GetSlideByPosition(pos)

'Get slide image

Dim img As Image

'For higher resolution, pass 2.0 as parameter

img = sld.GetThumbnail(1.0, 1.0)

'Gray out the slide image, see this code in attachment

grayscale(img)

'Add a new slide in destination presentation

Dim dstSld As Slide = dstPres.AddEmptySlide()

'Add image, see this code in attachment

AddImage(dstPres, dstSld, img)

Next ' End for

'Remove the default slide from destination presentation

dstPres.Slides.Remove(defaultSld)

'Write final presentation on disk

dstPres.Write("c:\outGray.ppt")

Thanks, for the code, the basic objective of converting color to grayscale is to reduce the .ppt size. Without actually running the code, I can see that it will have following potential prbolems:

1. Converting the slides to images will increase overall size. This will defeat my basic objective.

2. I will not be able to edit grayScale images.

#2 is still not a big problem, but I really need a resolution to #1. Please help

Unfortunately, Aspose.Slides do not provide such feature. Further, if I am not mistaken, it is the runtime behavior of MS-PowerPoint and user have to click on GrayScale View in PowerPoint to view in gray, everytime (s)he opens it. It means, PowerPoint does not store any color view information inside ppt and hence, Aspose.Slides cannot be used to manipulate such information.

Can you add this to your feature list for a future version. If yes, how early can we expect this feature.

Hello,

If I’m not mistaken you need convert to grayscale embedded images only because
changing color of other objects won’t reduce ppt size.

In this case you can read each image in a ppt file, convert it to grayscale and replace
old color image with new one. After adding new images to a collection you should
iterate all shapes on all slides and replace image identifiers.
That shouldn’t be too difficult.

Thanks for you suggestion. It might prove useful. I am able to follow all your steps except relacing older images with the newer one. How do I do it at the same position using Aspose API

You cannot change them at the same position; you will have to add a new image and then change the picture id of old PictureFrame with the new picture id.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Aspose.Slides will remove the unnecessary pictures automatically on writing.

I will ask, if technical team can add a new feature in Aspose.Slides, which could help user to insert new picture at the desired index of Presentation.Pictures collection