This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
JBZoo/Image is a PHP image manipulation library that provides an object-oriented wrapper around PHP's GD extension. The library supports image resizing, cropping, filtering, watermarking, and text overlays with support for GIF, JPEG, PNG, and WEBP formats.
src/Image.php- Main Image class that handles image loading, manipulation, and savingsrc/Filter.php- Contains image filter constants and filter application logicsrc/Text.php- Handles text rendering on images with font supportsrc/Exception.php- Custom exception class for image operations
- PHP Extensions:
ext-gd,ext-exif,ext-ctype(required for image operations) - JBZoo Libraries:
jbzoo/utils(utilities),jbzoo/data(data handling) - Dev Tooling:
jbzoo/toolbox-dev(provides development tools via Makefile)
make update # Install/update all dependenciesmake test # Run PHPUnit tests
make test-all # Run all tests and code quality checksmake codestyle # Run all linters and code style checksmake report-all # Generate all project reports
make report-coveralls # Upload coverage to CoverallsTests are located in tests/ directory with the following organization:
ImageTest.php- Core image manipulation testsFilterTest.php- Image filter functionality testsTextTest.php- Text overlay functionality testsResizeTest.php- Image resizing testsWatermarkTest.php- Watermark overlay testsTransformsTest.php- Image transformation teststests/resources/- Test images and fontstests/expected/- Expected test output images
The project uses PHPUnit with image comparison testing - many tests generate images and compare them against expected outputs.
The Image class accepts multiple input formats:
- File paths
- Base64 data URIs
- Raw binary data
- GD image resources
All manipulation methods return $this to enable fluent interface:
$img = (new Image('./source.jpg'))
->addFilter('grayscale')
->resize(320, 240)
->saveAs('./output.png');Filters are applied via addFilter() method with filter name and parameters. The Filter class contains constants for filter types (blur types, etc.).
The project uses GitHub Actions with three main jobs:
- PHPUnit: Runs tests across PHP 8.3, 8.4, 8.5 with different composer flags
- Linters: Runs code quality checks across PHP versions
- Reports: Generates coverage and static analysis reports
The Makefile integrates with jbzoo/toolbox-dev which provides standardized development commands across JBZoo projects.