Table of contents
Namespace: Com\Tecnick\Pdf\Filter\Type
Implements: Template
File: CcittFax.php line 57
CCITTFaxDecode filter (PDF 32000-1:2008 §7.4.6). Decompresses bi-level (1 bit per pixel) image data encoded with the CCITT facsimile standards (ITU-T T.4 Group 3 or T.6 Group 4), by wrapping the raw bitstream in a TIFF container and decoding it with the Imagick extension (ext-imagick). The result is a PNG image.
DecodeParms defaults (PDF 32000-1:2008 Table 11):
- K: 0 (= Group 3 1-D; negative = Group 4 / T.6; positive = Group 3 2-D)
- Columns: 1728 (standard fax width)
- Rows: 0 (decode until end-of-data)
- BlackIs1: false (0 bits are black)
- EncodedByteAlign: false (lines are not padded to a byte boundary)
EncodedByteAlign maps to TIFF T4Options bit 2 and so applies to Group 3 only; TIFF T6Options has no equivalent bit and it is ignored for Group 4.
When Rows is absent the image height is estimated from the encoded length as though the data were uncompressed, which under-estimates it and truncates the image. Pass Rows (the image dictionary /Height) to decode the whole image.
Tags
- since: 2011-05-23
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2011-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-pdf-filter
- phpstan-type: TiffTag array{tag: int, type: int, count: int, value: int}
- phpstan-type: TiffTagList array<int, TiffTag>
Methods
__construct()
File: CcittFax.php line 100
public __construct([array<string|int, mixed> $params = [] ]) : mixed
Parameters
- $params : array<string|int, mixed> = []: Optional DecodeParms dictionary (PDF 32000-1:2008 Table 11). - ‘K’ (int): compression mode; negative = pure 2-D (T.6 / Group 4), 0 = pure 1-D (T.4 / Group 3), positive = mixed 1-D/2-D (T.4 / Group 3 2-D). - ‘Columns’ (int): image width (default 1728). - ‘Rows’ (int): image height; 0 = unknown (default 0). - ‘BlackIs1’ (bool): whether 1 bits are black (default false). - ‘EncodedByteAlign’ (bool): whether each line starts on a byte boundary (default false).
decode()
File: CcittFax.php line 148
public decode(string $data[, array<string, mixed> $params = [] ]) : string
Parameters
- $data : string: Raw CCITT-compressed image data.
- $params : array<string, mixed> = []: Optional DecodeParms dictionary; when not empty it replaces the one given to the constructor.
Tags
- throws: Exception if Imagick is not available or decoding fails.
Return values
string —
Decoded PNG image bytes.