Click or drag to resize
Pdftools logo

Image Class

Inheritance Hierarchy
SystemObject
  PdfTools.Toolbox.InternalNativeBase
    PdfTools.Toolbox.InternalNativeObject
      PdfTools.Toolbox.Pdf.ContentImage

Namespace: PdfTools.Toolbox.Pdf.Content
Assembly: PdfTools.Toolbox (in PdfTools.Toolbox.dll) Version: 1.1.0+5820e9ca9ca173983539ffc40abc227fb62e6928
Syntax
C#
public class Image : NativeObject

The Image type exposes the following members.

Properties
 NameDescription
Public propertyBitsPerComponent

The number of bits per component.

The number of bits used to represent each color component. Only a single value may be specified; the number of bits is the same for all color components. Valid values are 1, 2, 4, and 8.
Public propertyColorSpace

The color space in which image samples are specified.

Public propertyDefaultImageType

Default extracted image type.

The default image type that will be extracted, based on the way that the image data is compressed and stored in the PDF file. The type of the output image is Jpeg for embedded JPEG and JPEG2000 images. In all other cases the image type will be Tiff.
Public propertySamples

The raw content of the image.

The samples (pixels) are given in order, top to bottom, left to right. Each sample is given component by component. There is no padding between components or samples, except that each row of sample data begins on a byte boundary. If the number of data bits per row is not a multiple of 8, the end of the row is padded with extra bits to fill out the last byte. Padding bits should be ignored.

Most often, each component is 8 bits, so there's no packing/unpacking or alignment/padding. Components with 2 or 4 bits are very rare.

If the image is compressed, it will be decompressed in order to get the samples. For very large images, this may take some time.

Public propertySize

The size of the image in samples.

Samples are often also called pixels.
Top
Methods
 NameDescription
Public methodStatic memberCreate

Create an image object from image data.

Supported formats are:
  • BMP
  • DIB
  • JPEG
  • JPEG2000
  • JBIG2
  • PNG
  • GIF
The returned image object is not yet painted on any page, but it is associated with the given target document.
Public methodEquals
(Inherited from NativeObject)
Public methodExtract

Extract embedded image from PDF

Facilitate the extraction of images from a specified page within a PDF, outputting them in the imageType format.

By default, the method determines the format of the extracted image based on the embedded image data present within the PDF. Users can ascertain the default image format through DefaultImageType. It's important to note that not all image types or conversion processes are universally supported, hence adhering to the default ImageType is advisable for optimal compatibility.

Key considerations include:

  • The extraction process isolates the image from the page's resources, neglecting any contextual attributes from the PDF page. Consequently, the original resolution and modifications—such as scaling, rotation, or cropping—that influence the image's appearance on the page are not preserved in the extracted image.
  • In instances where a GenericException error arises, the output file may be compromised and rendered unusable.

This method is designed to efficiently retrieve images without their page-specific modifications, ensuring a straightforward extraction process.

Public methodGetHashCode
(Inherited from NativeObject)
Top
See Also