Hi Pitky,
Thanks for your inquiry.
Images in Word documents are either represented by Shape nodes or by DrawingML nodes when loading into Aspose.Words’ DOM. Please read the members of DrawingML and Shape class from here:
https://reference.aspose.com/words/net/aspose.words.drawing/shape/
https://reference.aspose.com/words/net/aspose.words.drawing/shape/
Please use the GetShapeRenderer.Save method to save image into a stream or file. ImageSaveOptions allows to specify additional options when rendering document pages or shapes to images. Following code example shows how to save DrawingML and Shape to image file format (Jpeg) and insert it again into Document at same location.
Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
foreach (DrawingML dml in doc.GetChildNodes(NodeType.DrawingML, true))
{
MemoryStream stream = new MemoryStream();
// Save image to Jpeg
dml.GetShapeRenderer().Save(stream, new ImageSaveOptions(SaveFormat.Jpeg));
builder.MoveTo(dml);
// Insert image again
builder.InsertImage(stream);
dml.Remove();
}
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
MemoryStream stream = new MemoryStream();
// Save image to Jpeg
shape.GetShapeRenderer().Save(stream, new ImageSaveOptions(SaveFormat.Jpeg));
builder.MoveTo(shape);
// Insert image again
builder.InsertImage(stream);
shape.Remove();
}
doc.Save(MyDir + "Out.docx");