Use image areas to inspect page coordinates, image types, and to save embedded resources in the desired format.
Save images to streams
fromgroupdocs.parserimportParserwithParser("brochure.pdf")asparser:images=parser.get_images()ifimagesisNone:print("Image extraction isn't supported for this format.")elifnotimages:print("No images found")else:forimage_areainimages:# The image stream is a .NET MemoryStream; to_array() returns its byteswithimage_area.get_image_stream()asstream:data=stream.to_array()print(f"Read {len(data)} bytes from page {image_area.page.index+1}")
The following sample file is used in this example: brochure.pdf
Read 16247 bytes from page 1
Read 125180 bytes from page 1
Read 69728 bytes from page 1
Read 94989 bytes from page 1
Read 96241 bytes from page 1
Read 163435 bytes from page 2
Read 96241 bytes from page 2