tecnickcom/tc-lib-pdf-image
Image import and embedding utilities for PDF streams. Handles PNG/JPEG and GD-based formats, transparency, palettes, caching, alternate images, and object generation for PDF embedding. Part of the TCPDF ecosystem. Requires PHP 8.2+, gd, zlib.
Architecture fit. tc-lib-pdf-image is not a PDF generator; it is one leaf module in the TCPDF v3 stack (tc-lib-pdf, tc-lib-encrypt, tc-lib-file, and related packages). It owns the image pipeline only: import (PNG/JPEG native, others via GD), palette/transparency handling, alpha-mask extraction, ICC/profile metadata, caching keys, alternate images, and PDF object emission. For a Laravel application this means it is a low-level building block, appropriate only if we are standardizing on the tc-lib-pdf ecosystem. If our product need is "generate branded PDFs in a queue job," this package is the wrong entry point — we would adopt tc-lib-pdf as the orchestration layer and treat tc-lib-pdf-image as a transitive dependency whose behavior we validate rather than code against directly.
Integration feasibility. Composer/PSR-4 namespaced (\Com\Tecnick\Pdf\Image), framework-agnostic, no Laravel service provider, facade, config, or publishable assets. Integration work is therefore ours: a container binding for Import, config for allowed hosts/paths, an ImageCacheInterface adapter (Redis/PSR-16/filesystem), and an encryption/file-helper wiring path. The constructor signature (kunit, encrypt, fileHelper, imageCache) is explicit and easy to wrap. Requirements are PHP ≥ 8.2 plus gd and zlib — both must be present and pinned in our runtime images and CI; a missing gd is a hard failure, not a degraded mode.
Technical risk.
NOASSERTION while the README states GNU LGPL v3. Both cannot be true operationally; LGPL has copyleft obligations (notice, source availability for the library and modifications, relinking rights) that some legal teams will not accept for a distributed or SaaS product. This needs a written legal opinion before adoption, not after.File helper fetches from hosts/paths; misconfiguration yields SSRF and local file disclosure. The documented external cache is explicitly a trust boundary: cached bytes (image data, palette, ICC profiles) are embedded verbatim into generated PDFs, so cache poisoning becomes content injection into documents. The README itself warns to deserialize with allowed_classes => false. Decompression and malformed-image handling in GD is a known DoS vector (memory/CPU).3.14.6 implies lockstep versioning with tc-lib-pdf — upgrades must be planned as a set, not module-by-module.Key questions for the maintainer/vendor and our own teams:
NOASSERTION or LGPL-3.0? Can we obtain a written clarification?Import/ImageCacheInterface?tc-lib-pdf and PHP versions?Stack fit. Compatible at the language/runtime level but a poor fit as a directly consumed package. The correct Laravel shape is:
tc-lib-pdf (which pulls this in) rather than pinning tc-lib-pdf-image alone; pinning a leaf invites version skew against the orchestrator.PdfServiceProvider registering a singleton factory for the Import/document objects, with constructor arguments sourced from config/pdf.php.ImageCacheInterface adapter bound to our existing cache store (Redis), wrapping keys with a namespace and version prefix so cache format changes on upgrade cannot poison documents.allowedHosts / allowedPaths that default to empty/deny, not permissive. In a Laravel app the image allowlist should be the storage disk root only.Migration path.
barryvdh/laravel-dompdf, mpdf, or classic TCPDF: expect a rewrite of rendering code, not a swap. tc-lib-pdf v3 APIs differ materially from classic TCPDF (add() returning IDs, object-based document flow, explicit encrypt/file helpers).Compatibility. Enforce PHP ≥ 8.2 in composer.json and CI; verify ext-gd and ext-zlib in the Dockerfile and in every queue worker image (workers are the common gap). Confirm Laravel version floor: Laravel 11/12 are natural fits; Laravel 10 requires a PHP 8.2 runtime, which is feasible but narrows the support window. Confirm no conflict with existing image libraries (Intervention Image, Imagick) — they can coexist but duplicate processing work.
Sequencing.
allowed_classes => false and namespace/version keys.Maintenance. Low code churn expected for a leaf module, but coupled churn: upgrades to tc-lib-pdf will move this package's version, and the cache payload shape is not a public contract — our persistent cache must be treated as invalidatable on every upgrade (version-prefix the keys as insurance). Watch upstream for PHP minor-version support drops; PHP 8.2 is already approaching end-of-active-support, so a near-term bump to 8.3/8.4 is likely.
Support. Documentation is thin: a README plus generated API docs at tcpdf.org. There is no vendor SLA. Practical support model is internal ownership plus upstream issue tracker, with a fallback plan to fork under LGPL if the maintainer becomes unavailable — acceptable for a library, less so if we build a customer-facing document pipeline that cannot ship without it. Assign a named owner in the platform team.
Scaling. PDF generation with image embedding is CPU- and memory-bound, and image decode/re-encode dominates cost. Consequences:
memory_limit headroom; do not inline in web requests.ImageCacheInterface is the highest-leverage scaling control for repeated brand assets (logos, letterheads) across thousands of documents — the README explicitly frames this use case. Expect a large win on cache hit; near-zero on unique per-user images.Failure modes to instrument and alert on:
ext-gd/ext-zlib missing on a freshly scaled worker image → immediate total failure, no graceful degradation.allowed_classes => false.Ramp-up. A mid-level PHP developer can call Import::add() in an afternoon; becoming productive with the ecosystem (document object model, encryption helper, file helper semantics, coordinate units via kunit, cache lifecycle) is a 1–2 sprint effort, longer without prior TCPDF experience. Budget additional time for legal review, security review, and building the golden-file harness — collectively the dominant cost, well above the integration code itself.
How can I help you explore Laravel packages today?