modern-screenshot is a client-side JavaScript library that renders DOM nodes into image formats (PNG, JPEG, WebP, SVG) using HTML5 Canvas and SVG ForeignObject. It clones a DOM subtree, captures computed styles (including pseudo-elements, scrollbars, CSS custom properties), embeds external resources (images, fonts, SVG symbols), and produces a bitmap or data URL. The architecture is modular: a recursive clone phase captures structure and styles, an embedding phase resolves and inlines external assets, and a rendering phase converts the cloned DOM to a Canvas via an intermediate SVG foreignObject. It supports Web Workers for parallel resource fetching, singleton context for repeated screenshots, DPI control via PNG/JFIF metadata injection, and comprehensive edge cases (shadow DOM, cross-origin iframes, @font-face with CSS layers, and Safari/Firefox quirks). The codebase is well-structured, thoroughly tested with Puppeteer-based image snapshot tests, and actively maintained.
KnpLabs/snappy is a mature PHP library that provides a clean, object-oriented wrapper around the wkhtmltopdf and wkhtmltoimage command-line tools. It enables generation of PDF documents and image thumbnails from HTML content or URLs. The library is architected around an abstract base class (AbstractGenerator) that implements the template method pattern, handling command construction, process execution via Symfony Process, temporary file management, and PSR-3 logging. Concrete subclasses (Pdf and Image) define their own option sets and handle special cases like converting inline HTML strings to temporary files for header/footer content. The library is widely used in the PHP ecosystem, with dedicated Symfony and Laravel integration bundles. It requires PHP 8.1+ and depends only on symfony/process and psr/log, making it lightweight and easy to integrate.