Free Support Forum - aspose.com

How to scale shape

Dear Team,

If I just specify the width of the shape that I want to insert, is there a way to make the height also scaled proportionally?

For example the real size of the image is 50x50, If, like the example below, Ionly specify the width (100), how to make the Height also proportionally automatically adjusted without specifying the Height property?

Aspose.Words.Drawing.Shape imageLogo = builder.InsertImage(imageBytes);

imageLogo.Width = 100;

Thanks,

Regards,

Anthony

Hi

Thanks for your inquiry. There is no direct way to scale the image when you set only width, but you can easily calculate height. You can use formula like the following:

double targetHeight = (targetWidht / originalWidht) * originalHeight;

Best regards,