import type { PDFRef } from '../core/pdf-ref.ts'; import type { ColorSpace } from './colors.ts'; import { ICCColorSpace } from './icc-color-space.ts'; import type { PDFContext } from './pdf-context.ts'; import { PDFResource } from './pdf-resource.ts'; export type JpegOptions = { /** ICC color profile to use instead of the device color space. */ colorSpace?: ICCColorSpace; /** * When `true`, any ICC color profile embedded in the JPEG data is * ignored and the device color space is used instead. Has no effect * when an explicit `colorSpace` is provided. Defaults to `false`. */ ignoreEmbeddedProfile?: boolean; /** * CMYK JPEGs produced by Adobe Photoshop encode channel values using * an RGB-like numeric convention 0='off', 1='max'. Those images will * appear with inverted colors in PDF viewers, since PDF interprets * CMYK channel values as ink coverage (0='no ink', 1='full ink'). * * Setting this option to `true` will invert CMYK color values to be * compatible with such JPEGs. This property is ignored for non-CMYK * images or when an ICC profile is provided. Defaults to `false`. */ invertCmyk?: boolean; }; export type PngOptions = { /** ICC color profile to use instead of the device color space. */ colorSpace?: ICCColorSpace; /** * When `true`, any ICC color profile embedded in the PNG data is * ignored and the device color space is used instead. Has no effect * when an explicit `colorSpace` is provided. Defaults to `false`. */ ignoreEmbeddedProfile?: boolean; }; /** * Represents an image resource within a PDF document. */ export declare class PDFImage extends PDFResource { readonly key: string; private readonly data; private readonly _width; private readonly _height; private readonly _colorSpace; private readonly _bitsPerComponent; private readonly _filter; private readonly _decodeParms?; private readonly _sMask?; private readonly _invertCmyk?; /** * Creates a PDFImage from JPEG data. * Automatically extracts dimensions and color space from the JPEG header. * * @param data The raw JPEG image data. * @returns A new PDFImage instance. * @throws Error if the data is not a valid JPEG or if required metadata cannot be extracted. */ static fromJpeg(data: Uint8Array, options?: JpegOptions): PDFImage; /** * Creates a PDFImage from PNG data. * Automatically extracts dimensions, color space, and alpha channel from the PNG. * * Supported PNG features: * - Color types: grayscale, RGB, palette, grayscale with alpha, RGBA * - Bit depths: 8 and 16 bits per component * - Transparency: alpha channels are extracted into a soft mask (SMask) * * Unsupported PNG features: * - Interlaced images (Adam7 interlacing) * - Ancillary chunks (tRNS for palette transparency, gAMA, cHRM, etc.) * * @param data The raw PNG image data. * @returns A new PDFImage instance. * @throws Error if the data is not a valid PNG, uses unsupported features, * or if required metadata cannot be extracted. */ static fromPng(data: Uint8Array, options?: PngOptions): PDFImage; private constructor(); /** * The width of the image in pixels. */ get width(): number; /** * The height of the image in pixels. */ get height(): number; /** * The color space of the image. */ get colorSpace(): ColorSpace; /** * The number of bits per color component. */ get bitsPerComponent(): number; register(context: PDFContext): PDFRef; }