Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Fast Image Size

Fast Image Size Laravel Package

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.

View on GitHub
Deep Wiki
Context7

fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.

Frequently asked questions about Fast Image Size
Is marc1706/fast-image-size a Laravel package?
No. It is a framework-agnostic PHP library with no service provider, facade, config file, or published assets. In Laravel you install it with Composer and wrap it in a small application service such as an ImageDimensionResolver. Treat it as a leaf dependency rather than a package you configure.
How do I install marc1706/fast-image-size in a Laravel app?
Run composer require marc1706/fast-image-size and let Composer resolve the version against your PHP constraint. There is nothing to publish or register. For custom HTTP behaviour such as timeouts, allow-lists, or auth headers, add a thin adapter around the library and bind it in a service provider.
Does fast-image-size work with Laravel 10, 11, or 12?
Yes, as long as your PHP version satisfies the library's Composer constraint, because it has no Laravel-specific integration. It does not depend on Laravel framework classes, so framework upgrades do not usually affect it. Check the package's composer.json for the exact PHP requirement before adopting it.
How is fast-image-size different from PHP getimagesize()?
It returns the same kind of width, height, and image-type data but reads only the header bytes instead of downloading or loading the whole file. That makes it faster and lighter for remote URLs and large images. It is designed as a quick drop-in alternative for dimension lookups, not a full image-processing library.
Can I get image dimensions from a remote URL with fast-image-size?
Yes. The library can read dimensions from a remote URL by fetching only the bytes it needs from the image header. In v1.3.1 it may parse a response even when the HTTP status is not 200 if bytes are present, so validate status codes at your call site. Pair it with your own HTTP policy for timeouts, redirects, and host allow-listing.
Which image formats does marc1706/fast-image-size support?
It supports common web formats including JPEG, PNG, GIF, BMP, and WebP, plus additional header formats listed in the README. Support is based on reading format headers, so it works without GD or Imagick extensions. Verify the current list for your version if you depend on newer formats such as AVIF.
What happens when fast-image-size cannot determine the dimensions?
The library generally returns null or false instead of throwing an exception, so callers must handle unknown dimensions explicitly. Decide on a product fallback, such as a placeholder, a queued retry, or rejecting the media import. Do not let nulls flow into the UI and break aspect ratios.
Is it safe to pass user-supplied URLs to fast-image-size?
The library is not a security boundary and does not protect you from server-side request forgery. You must enforce scheme and host allow-listing, block private and link-local IP ranges at resolution time, and handle redirects carefully. Get application-security sign-off before exposing any untrusted-URL flow.
How should I test fast-image-size in a Laravel application?
Use local fixture images and Storage::fake so tests do not hit real origins. Cover the cases that matter for remote lookups: 200, 206 Partial Content, redirects, 404 responses with a body, and HTML error pages. For production, run remote lookups in queued jobs with timeouts and cache the resolved dimensions.
Is marc1706/fast-image-size actively maintained, and what are the alternatives?
It is a small, single-maintainer project with infrequent releases and a very small API surface, so review the changelog for semantic changes such as the v1.3.1 status-handling change. Alternatives include PHP's getimagesize(), Intervention Image, or a small custom header parser. Because the API is tiny, replacing it later is inexpensive.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table