marc1706/fast-image-size
Fast, dependency-free PHP library that reads image dimensions from file headers without loading the whole file, supporting JPEG, PNG, GIF, BMP, WebP, and more. A quick drop-in alternative to getimagesize for speed and low memory use.
width/height on <img> tags to avoid layout shift (a measurable Core Web Vitals win).width/height/type columns that were never captured — a data-quality project that would otherwise look too expensive to schedule.200 status. In practice this is exactly the CDN/object-store case: 206 Partial Content from range requests (the library's happy path) and signed URLs now parse instead of failing. Fewer "could not determine image size" errors, fewer failed imports, fewer support tickets.403/404/500 that happens to carry image bytes may now parse successfully. If any workflow treats "probe failed" as a proxy for "this URL is dead" (dead-link cleanup, retry logic, alerting), that signal must move to the HTTP layer. Decide this before rollout — it changes the semantics of an existing monitoring feature, not just a dependency version.Adopt it when:
Look elsewhere or defer when:
image validation rule); a second probe adds latency for no new information.To executives: A small, single-purpose open-source dependency that tells us an image's dimensions and format by reading a few hundred bytes instead of the whole file. That lowers compute and memory on import and backfill jobs, improves page rendering through correctly sized images, and saves engineering time we would otherwise spend maintaining our own parser. The v1.3.1 patch is a low-risk bug fix that makes remote reads succeed more often against our CDN and object storage, directly reducing failed imports and support load. Cost is effectively zero, risk is low, and it carries no framework lock-in. The one condition we are attaching: any user-supplied URL path ships only after a security review of the fetch layer.
To engineering: Header-only image probing — no GD/Imagick needed for metadata. Pure PHP and framework-agnostic, so it drops into jobs and Artisan commands; wrap it in a thin resolver service and bind the PSR-18 client plus a cache adapter in a service provider so the library stays replaceable. Pin to ^1.3; upstream is a single maintainer, so treat upgrades as deliberate, tested events. Plan around three known characteristics: it returns null/false on failure rather than throwing (handle "unknown dimensions" explicitly or nulls reach the UI), it needs SSRF guards and per-host timeouts at the client layer, and v1.3.1 changed error semantics — probe success no longer implies a 2xx, so keep explicit status validation wherever that distinction drives behavior. Minimum test set before rollout: 200, 206, redirect chains, 404/503 with an HTML body (must be rejected, not misparsed), and truncated responses. Roll out behind a flag on one low-risk surface, such as link previews, before it backs user-facing media metadata.
How can I help you explore Laravel packages today?