rekalogika/file-image
Adds image support to rekalogika/file: image files are identified, validated, and can be resized or converted into derivatives such as thumbnails. Works with the file abstraction, so dimensions, MIME type, and metadata are available wherever files are used in your PHP app.
Architecture fit. This is not a standalone imaging library — it is a filter plugin for rekalogika/file, a filesystem-abstraction + attachment/metadata + filter-pipeline library. Its entire public surface is essentially one filter class that accepts a max width, max height, and a square-crop flag, and delegates the actual pixel work to the parent package's image-processing contract. That means the package's architectural value is conditional on adopting rekalogika/file as your attachment model. If your application already stores files as Doctrine entities/attributes wrapped by that library, this is a natural, low-ceremony addition. If your application uses Laravel's Storage facade + HasMedia-style models or Spatie's media library, this package sits on the wrong side of an abstraction boundary and you would be adopting a whole parent framework to get one resize call.
Integration feasibility. Mechanically straightforward: composer require, wire the filter into the parent library's filter registry, invoke with three arguments. The real cost sits in the prerequisites — the parent rekalogika/file package, a Flysystem adapter bound to your storage, and a working GD or Imagick extension in every environment that renders images (including queue workers and CI). Budget the majority of integration effort against the parent, not this package.
Stack-fit caveat. The task framing says "Laravel/PHP package," but the rekalogika family is Symfony/Doctrine-leaning (rekalogika/file-bundle, Doctrine listeners, Flysystem). Laravel support is DIY: you will hand-roll the container bindings and storage adapter. Do not assume a Laravel service provider ships with it — verify before committing.
Technical risk. High, concentrated in supply chain rather than code quality:
memory_limit exhaustion from a 40MP JPEG is a realistic outage).Key questions to answer before any commitment:
rekalogika/file, or are we about to adopt a second attachment abstraction alongside Laravel's filesystem?Stack fit. Treat this as a capability, not a dependency. The correct integration shape is to place it behind an interface you own:
App\Imaging\ImageTransformer (your interface: resize(File, maxW, maxH, crop): File)
└── RekalogikaImageTransformer (adapter, the only file importing the package)
└── InterventionImageTransformer (fallback / swap target)
This costs one afternoon and converts a bus-factor-1 dependency into an interchangeable detail.
Migration path. Two viable routes, chosen by whether you already own the parent abstraction:
rekalogika/file: greenfield filter adoption. Add the package, register the filter, migrate the highest-traffic image call sites one at a time behind your new interface. Low risk.spatie/image (~50 lines), and keep this repo open as a reference implementation. Route B is the recommendation for the overwhelmingly common case, and it is the cheaper path even accounting for writing the code.Compatibility checks (gate items, not nice-to-haves):
rekalogika/file version constraint — pin exact, since subpackage tags track the monorepo.Sequencing.
storage directly.Maintenance. Low code churn (thin wrapper) but non-zero process overhead: you must watch the monorepo release feed, not this repo, and pin exact versions because subpackage tags move with the parent. Vendor or fork on day one if the spike passes — the cost is one composer.json repository entry and it eliminates the "upstream archived, we can't ship a security patch" scenario. Expect to own the code within 12–18 months either way.
Support. Community-only, effectively single-maintainer, with no searchable issue corpus at this package's adoption level. Internalize the expectation that your team is the tier-2 support for this filter. That is acceptable for ~a resize call; it is not acceptable if imaging is on a revenue-critical path (marketplace listings, user avatars at scale, document previews).
Scaling. Resizing is CPU- and memory-bound, not I/O-bound, and it scales linearly with upload volume unless derivatives are cached. Concretely:
(source hash, maxW, maxH, crop). Without this, a listing page with 24 thumbnails re-decodes the same originals on every render.Failure modes to instrument and alert on:
getimagesize before decoding.Ramp-up. The API surface is trivial — an engineer understands it in under an hour. The real ramp-up is the parent rekalogika/file model: file abstractions, filters, metadata, and Flysystem binding, which is a multi-day mental model for a team not already on it. That asymmetry — one-hour API, multi-day substrate — is the single strongest argument for Route B. If you do adopt it, assign one engineer as owner, have them write a one-page runbook covering the failure modes above, and require the fallback implementation to remain compiled and tested so a swap is a config change rather than a migration.
How can I help you explore Laravel packages today?