ps/image-optimizer
PHP library that shrinks JPEG, PNG, GIF, SVG, and WebP images by wrapping tools like jpegoptim, optipng, pngquant, gifsicle, svgo, and cwebp. Offers a simple API, optimizer chains, and smart format-based optimization for lossless or lossy compression.
Architecture fit
ps/image-optimizer is a framework-agnostic PHP orchestration library, not a Laravel package. There is no service provider, facade, publishable config, queue hook, or event integration. It exposes a small composition API: assemble an OptimizerChain from optimizer objects (Optipng, Pngquant, Jpegoptim, Gifsicle, Svgo, etc.) and call optimize($source, $destination).ImageOptimizer contract, so the vendor decision (this package vs. Spatie's wrapper vs. a managed CDN) stays reversible without touching call sites. Treat the interface as the product surface and the package as an implementation detail.Integration feasibility
optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim, jpegtran, and svgo at known absolute paths across app containers, worker containers, and CI.Technical risk
pngquant, aggressive jpegoptim) are irreversible and visibly observable. Without agreed quality thresholds and a visual-regression check, this becomes a customer-facing incident rather than an engineering ticket.Key questions
/tmp limits).Stack fit
ImageOptimizerInterface in a service provider with two implementations: the ps/image-optimizer adapter and a no-op passthrough for local and test environments.config/images.php: absolute binary paths, per-format optimizer chains, quality levels, process timeout, max input size, and a global kill-switch flag. Binary paths and quality values must not live in application code.Storage::disk('local') scratch workspace — pull from S3, optimize locally, push result back. Do not attempt to stream object storage through the optimizer.Migration path
Compatibility
Sequencing
Spike + PHP-matrix verification → Toolchain baked into base image and CI → Adapter interface + config + feature flag → Queued job with timeout, retry, and input-size guard → Pilot on one surface with quality metrics → Backfill with originals retained → Default-on and decommission of the legacy path.
Run the legal/licensing review in parallel with the spike — it is the most likely late-stage blocker and the cheapest thing to start early. Gate each arrow with an explicit go/no-go so the project can stop cleanly at any step.
Maintenance
Support
Process failures surface with opaque stderr; map them into a small taxonomy (binary missing, timeout, corrupt/unsupported input, disk full) and attach original-file metadata to logs so triage does not require reproducing customer files.Scaling
images queue with its own worker pool so a bulk backfill cannot starve transactional jobs.Failure modes
finally blocks.Ramp-up
How can I help you explore Laravel packages today?