We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Crop Image

Hi,


How to read cropped image from ppt.


regards
khushboo

Hi Khushboo,


Thank you for posting.

I have observed your comments but I am unable to understand it completely. If you want to extract images from a slide then I would like to share with you that an image is contained inside a Picture frame which is basically a shape. You can iterate through the shapes and check for the the shape if that is a picture frame, as in the code below. Also, you can find any shape as explained in this documentation article and then create a thumbnail of the shape as explained in this documentation article.

Presentation pres = new
Presentation(@“D:\Test.pptx”);<o:p></o:p>

foreach (Slide slide in pres.Slides)

{

foreach (IShape shape in slide.Shapes)

{

if (shape is PictureFrame)

{

//Create Thumbnail Here

}

}

}


I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Hi,


Thanks for the reply.
I am able to read image inside shape.PictureFormat.Picture.Image.BinaryData, and cropped position inside shape.PictureFormat.CropTop.

Is there any way to read cropped image BinaryData only.

Presentation pres = new Presentation(@“D:\Test.pptx”);<o:p></o:p>

foreach (Slide slide in pres.Slides)<o:p></o:p>

{<o:p></o:p>

foreach (IShape shape in slide.Shapes)<o:p></o:p>

{<o:p></o:p>

if (shape is PictureFrame)<o:p></o:p>

{<o:p></o:p>

var img=<o:p></o:p>shape.PictureFormat.Picture.Image;

var cropFormat=shape.PictureFormat;

using (Stream stream = File.OpenWrite(""))

{

stream.Write(shape.PictureFormat.Picture.Image.BinaryData, 0, shape.PictureFormat.Picture.Image.BinaryData.Length);

}

}<o:p></o:p>

}

}

Hi Khushboo,


I have observed your comments and like to share with you that the cropped image is not saved as another copy of image but the original image appears in a way that it looks cropped. Now, as per your requirements you may create a thumbnail of the shape in the bounds of its appearance as explained in this documentation article.

I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Hi,


Thanks for reply.
It is helpful.

Hi Khushboo,


Thank you for your kind feedback.

Please feel free to contact us if we could be of any help to you.

Best Regards,