Sample code references code that does not appear to exist in the Aspose library

On this page
https://reference.aspose.com/words/python-net/aspose.words/documentbuilder/insert_image/

The example that is labelled “Shows how to insert an image from a byte array into a document.” has a line:

image = drawing.Image.from_file(IMAGE_DIR + "Logo.jpg")

However, nowhere on this page does it show where this drawing module comes from, and when I try to run

image = aw.drawing.Image.from_file("jpeg/input.jpeg")

I get the error:

AttributeError: module 'aspose.words.drawing' has no attribute 'Image'

What module is this code referencing?? I can’t find documentation on it anywhere.

@acn you should use aspose.pydrawing module:

import aspose.words as aw
import aspose.pydrawing as pydraw

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

image = pydraw.Image.from_file("C:\\Temp\\logo.png")
with io.BytesIO() as stream:
    image.save(stream, pydraw.imaging.ImageFormat.png)
    image_byte_array = bytes(stream.getvalue())
    builder.insert_image(image_byte_array)

doc.save("C:\\Temp\\out.docx")

Thank you. Can you please update the documentation to be accurate and specific?

@acn Sure, we will improve our documentation to make it more clear. Thank you for pointing the problem.