Free Support Forum - aspose.com

How to get the original size of image inserted in document?


#1

Hi, Support,

I have a question that how to get the original size of image inserted in document?
for example ,the original size of an image is 3000x2000, it’s new size will be adjusted to 480x320 when it’s inserted to a document. Therefore, how to use aspose.words.dll to get its original size?

Thanks for your help!


#2

@ducaisoft

Thanks for your inquiry. The Shape class represents an object in the drawing layer, such as an AutoShape, textbox, freeform, OLE object, ActiveX control, or picture.

You can check either shape is image or not using Shape.HasImage property. The Shape.ImageData property provides access to the image of the shape. You can get the information about image size and resolution using ImageData.ImageSize property.

Please let us know if you have any more queries.


#3

Thanks for your suggestion.
And how to replace the picture to a new one? Could this code like “Shape.ImageData.SetImage(NewImageFile)” work for this purpose?


#4

@ducaisoft

Thanks for your inquiry. Yes, you can use ImageData.SetImage method to achieve your requirement.

You can also achieve your requirement by moving the cursor to the Shape node, insert new image and remove the shape node using Shape.Remove method.