Imagine

Object-oriented PHP image manipulation library with pluggable GD, Imagick, and Gmagick drivers.

Library
Composer
v1.5.4
4,470stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
68/100Good
Development Activity40
Maintenance44
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture85
Code Quality80
Innovation80
Learning Curve70

Imagine is an object-oriented PHP library for image manipulation that abstracts away the underlying imaging extension behind a consistent, expressive API. It ships three interchangeable drivers — GD, Imagick, and Gmagick — so the same code can run wherever any of those extensions is available, and it models images, colors, boxes, points, and layers as first-class objects.

Beyond basic resize and crop, Imagine provides drawing primitives, image effects and filters, font and text rendering, layer handling for animated formats, and format conversion. Its transformation and filter pipeline lets you compose reusable image operations that can be applied consistently across many images.

What You Get

  • A unified ImagineInterface/ImageInterface API backed by GD, Imagick, and Gmagick drivers
  • Geometry value objects — Box, Point, and coordinate helpers for precise transformations
  • Drawing primitives for lines, ellipses, polygons, arcs, and text
  • Effects and filters (grayscale, blur, colorize, gamma) plus a composable transformation pipeline
  • Layer handling for multi-frame images and broad format read/write support

Common Use Cases

  • Generating resized thumbnails and responsive image variants from user uploads
  • Applying watermarks, overlays, and text to images programmatically
  • Normalizing and converting images between formats (JPEG, PNG, WebP, GIF) in a portable way

Under The Hood

Architecture — Imagine is organized around a set of interfaces in src/Image/ImagineInterface (the entry-point factory that opens, loads, or creates images), ImageInterface/ManipulatorInterface (resize, crop, rotate, paste, save), LayersInterface, FontInterface, and geometry types like Box and Point. Each imaging backend lives in its own namespace (src/Gd, src/Imagick, src/Gmagick) providing concrete Imagine, Image, Drawer, Effects, Font, and Layers implementations plus a DriverInfo. A ClassFactory (src/Factory) decouples object construction so drivers can be swapped or extended without changing calling code. Color handling is abstracted through a Palette system (RGB, CMYK, grayscale) under src/Image/Palette.

Tech Stack — Pure PHP targeting php >=7.1 with no required runtime dependencies; the imaging extensions (ext-gd, ext-imagick, ext-gmagick, ext-exif) are declared as suggestions and chosen at runtime. Tests run on a wide PHPUnit range (4.8 through 9.x) to support the broad PHP-version matrix.

Code Quality — The library leans heavily on interfaces and abstract base classes (AbstractImage, AbstractImagine, AbstractLayers, AbstractFont) to share behavior across drivers, and ships a substantial test suite under tests/tests/ with fixtures and driver-parameterized cases. A dedicated Exception namespace gives typed error handling. The mature, layered design reflects over a decade of production use.

API Design — The public surface is fluent and discoverable: you instantiate a driver’s Imagine, call open()/create(), then chain manipulation methods that return the image for further operations before save(). Geometry and color as value objects make intent explicit, and the consistent driver contract means code written against GD ports unchanged to Imagick or Gmagick.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search