Extract an image from an image annotation

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Annotation MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-annotation -- dnx GroupDocs.Annotation.Mcp --yes
Folders, licensing and more →

On this page

You can extract an image from the ImageAnnotation object. To do this, call the ImageAnnotation.GetImage() method.

The following code snippet shows how to extract an image from an image annotation:

using (Annotator annotator = new Annotator("annotated_file.docx"))
{
	List<AnnotationBase> annotations = annotator.Get();
	for (int i = 0; i < annotations.Count; i++)
	{
		if (annotations[i] is ImageAnnotation imageAnnotation)
		{
			Image image = imageAnnotation.GetImage();
			image.Save($"extracted_image{i + 1}.{imageAnnotation.ImageExtension}");
		}
	}
}

On this page