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

Free Support Forum - aspose.com

Aspose.Slides Picture alignment

Hi guys.
I need to align on center picture which I add into slide,
how to do that?

Here is my code:

private void AddPicture(SlideEx slide, MemoryStream ChartStream, float coordinateX, float coordinateY)
if (ChartStream == null)

System.Drawing.Image img = (System.Drawing.Image)new Bitmap(ChartStream);
ImageEx imgx = presentation.Images.AddImage(img);
slide.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, coordinateX, coordinateY, (Convert.ToInt32(imgx.Width * 0.67)), (Convert.ToInt32(imgx.Height*0.67)), imgx);



Thanks for inquiring Aspose.Slides.

I have observed the inquiry shared by you. Can you please share the sample application along with generated presentation with us. Please also share the desired output presentation with us as well. I will observe the requirement based on availability of requested information to help you further.

Many Thanks,

Hi Mudassir,

I provided a single and very simple method.
I don’t know if I can add some additional info regarding my issue.


I have observed the sample code shared and its adding only the picture frame. As requested earlier, can you please provide the generated presentation and expected output presentation. Based on your presentations, I will carry my investigation to help you with possible sample code to achieve that.

Many Thanks,


I’m attaching zip files.

1) SlideReport_ImageAlignment.pptx - actually slide report. (small part of it)

2) On the files Centered_Image.jpg and Centered_2_Images.jpg you’ll find how I’d like to make images centered.

3) And of course instead of creating images in slide report from Stream object,
like in my source code:
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(ChartStream);
ImageEx imgx = presentation.Images.AddImage(img);

you may load prepared images:



I have observed the requirement shared by you and like to share that there is no such option available even in PowerPoint to set or align the image to center of slide. One need to implement his own logic for setting the position of the image to center of slide. Please use the sample code shared below as an example to carry out your implementation.

public static void addPicFrame()
//Instantiate PrseetationEx class that represents the PPTX
PresentationEx pres = new PresentationEx();

//Get the first slide
SlideEx sld = pres.Slides[0];

float centerX = pres.SlideSize.Size.Width/2;
float centerY = pres.SlideSize.Size.Height/2;

//Instantiate the ImageEx class
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(“d:\Aspose Data\Penguins.jpg”);
ImageEx imgx = pres.Images.AddImage(img);

float imagePosX = centerX - (imgx.Width/2);
float imagePosY = centerY - (imgx.Height/2);

//Add Picture Frame with height and width equivalent of Picture
int id = sld.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle, imagePosX, imagePosY, imgx.Width , imgx.Height, imgx);
PictureFrameEx picfram = (PictureFrameEx)sld.Shapes[id];
//Write the PPTX file to disk
pres.Write(“d:\Aspose Data\RectPicFrame.pptx”);

For your kind reference, I have also attached the generated presentation as well.

Many Thanks,