Extracting images

edit

GetImages returns the images the content of a page paints, in the order they are painted:

foreach (var image in page.GetImages())
{
    // Where the image is on the page, and its pixels, with its color space and its soft mask applied
    var bounds = image.Bounds;
    using var decoded = image.Decode();
}
  • The image XObjects painted by the content, or by the forms it paints, and the inline images are included. An image painted several times is returned each time, with the same Reference.
  • Matrix maps the unit square of the image to the page, and Bounds is the rectangle it covers.
  • EncodedData and Filters give the data as it is stored: the data of a DCTDecode image is a JPEG file. Dictionary, ColorSpace and SoftMask give its attributes.
  • Decode returns the pixels in RGBA: the color space converted to sRGB, the decode array applied, and the mask or the soft mask as the alpha channel. It applies the limits of the read options of the document. Dispose of the image.
  • The images of the annotations, of the patterns and of the soft masks are not included.