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

Free Support Forum - aspose.com

Adding a Picture Frame with the Right Aspect Ratio

example.zip (103.8 KB)
Hello,

a big thanks for the aspose teams for the big help that ou provide for all our componenet (diagram,cells,words…).

our problem is simple. We have a png picture generated and we want to add it to a slide using the function AddPictureFrame. The problem is that the function stretch the image and the result is nit that readable. In the attached file you will find two Files. the first one is the real picture generated (tempImg.png) and the second one is the ppt file generated with the picture.(tempFile.ppt).

is there any function in aspose slide that helps making the god aspect ration between the generated picture and the frame created ?

one important thing is that we are still working with an old version (12) and we are wondering if there is anything in the set of the new versions that can help.

here is my code :
in = new FileInputStream(this.tempImgAbsolutePath);
Picture pic = new Picture(this.pptFile, in);
int picId = this.pptFile.getPictures().add(pic);
final int _X_PPT_DIAGRAM = 820;
final int _Y_PPT_DIAGRAM = 700;
final int _WIDTH_PPT_DIAGRAM = 4000;
final int _HEIGHT_PPT_DIAGRAM = 3200;
slide.getShapes().addPictureFrame(picId, _X_PPT_DIAGRAM, _Y_PPT_DIAGRAM, _WIDTH_PPT_DIAGRAM, _HEIGHT_PPT_DIAGRAM);

We want also now what’s the measure units used in aspose slide for the height and the width ?
i couldn’t found any reference in the documentation for this question.

@eljuventino,
Thank you for posting the inquiry.

It will take me a while to perform some research for you. We will reply to you as soon as possible.

@eljuventino,
To add an image to a slide while maintaining the aspect ratio, you need to know the dimensions of the image and the dimensions of the slide anyway. Then, based on this data, you calculate the size of the picture frame, proportional to the size of the image. Then add the image to the slide.

Unfortunately, I am not aware of such a function. It may have many nuances to implementation. We could consider your requirements. Could you please describe how this should work?

Unfortunately, I don’t have information for older versions of Aspose.Slides. Typically, slides and shapes are measured in points.