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

Phpthumb Laravel Package

weotch/phpthumb

Composer package for phpThumb, the PHP image thumbnail library. Generate resized, cropped, and watermarked images from source files with caching and support for GD or ImageMagick. Useful for legacy PHP projects needing on-the-fly thumbnails.

Deep Wiki
Context7

PHP Thumbnail & Image Manipulation Library

Frequently asked questions about Phpthumb
How do I install weotch/phpthumb in a Laravel project?
Install it with Composer using composer require weotch/phpthumb. Because it is a plain PHP library wrapper around phpThumb rather than a Laravel package, there is no service provider to register and no config file to publish. Laravel's Composer autoloading means you can instantiate the phpThumb class directly in a controller, job, or service class. Point the source at a local file path and write the generated image wherever you need it.
Does weotch/phpthumb work with Laravel 10 or 11?
The package is framework agnostic, so it is not tied to a specific Laravel release and can be used in Laravel 10, 11, or older versions. The real constraint is the PHP version required by the package's Composer metadata, which you should check with composer show weotch/phpthumb before installing. If your application runs a supported PHP version, the library will load and run normally. Always run your test suite after adding it to confirm compatibility with your project's PHP version.
Do I need GD or ImageMagick to generate thumbnails?
phpThumb can use either the GD extension or ImageMagick as its image processing backend. GD ships with most PHP installations and is usually the simplest choice, while ImageMagick typically produces better quality output and handles more formats. Check which one is available on your server with phpinfo or php -m, and make sure the corresponding binary or extension is present in production. If neither backend is available, thumbnail generation will fail at runtime.
How do I crop an image to exact dimensions with phpThumb?
You set the target width and height parameters and enable zoom cropping, which scales the image to fill the requested box and then trims the overflow from the center. This guarantees the output matches the exact dimensions you asked for, which is what you want for uniform grid thumbnails and avatars. If you prefer letterboxing instead of cropping, simply leave zoom crop disabled and the library will fit the image inside the box while preserving the aspect ratio. Always verify the result with getimagesize in a test, since rounding can occasionally produce a one-pixel difference.
Can weotch/phpthumb add watermarks, borders, and filters to images?
Yes. phpThumb exposes parameters for overlaying a watermark image, drawing borders, and applying filters such as grayscale or color adjustments. Watermarking requires a path to a local watermark file plus positioning and opacity settings. Because these operations happen at generation time, it is worth caching the output so you are not re-rendering watermarks on every request.
How do I control output format and JPEG quality?
The library lets you specify the output image format and the compression quality through its configuration parameters before rendering. Setting the format explicitly is useful when you want PNG output with transparency or a compressed JPEG for web delivery. Choose a quality value that balances file size against visible artifacts, and keep it consistent across your application. Keep in mind the available formats depend on which backend, GD or ImageMagick, is active on the server.
Does phpThumb cache generated thumbnails?
phpThumb includes a caching layer that writes generated images to a configured cache directory and reuses them based on the source file and parameters. You need to create that directory and make it writable by the web server or queue worker. In a Laravel application the natural location is something like storage/app/thumbnails, ideally outside the public web root. Caching is what makes on-the-fly resizing practical, so enable it before going to production.
Can I generate thumbnails from remote URLs or S3 files?
The library is designed around local image sources, not remote URLs or cloud storage streams. The reliable pattern is to download or copy the source file to a local temporary path first, generate the thumbnail, then store or upload the result. In Laravel you can pull the file with the Storage facade, write it to a temp directory, and pass that path to phpThumb. This also gives you control over timeouts, file size limits, and cleanup.
How should I test image generation in a Laravel test suite?
Generate thumbnails into a temporary directory in your test and assert that the output file exists and matches the expected dimensions and MIME type using getimagesize. Use Storage::fake or a dedicated temp path so tests never write into your real public assets. Keep a small fixture image in tests/Fixtures and avoid depending on external files or URLs. This catches backend problems, like a missing GD extension, early in CI.
Is weotch/phpthumb still maintained, and what are the alternatives?
This package is a Composer wrapper around the older phpThumb library, so it is best treated as a legacy-friendly option rather than an actively evolving one. For new Laravel projects, intervention/image, spatie/image, and league/glide are more modern choices with active maintenance, PSR-compliant APIs, and first-class framework integration. Pick weotch/phpthumb when you need its specific parameter-driven behavior or are maintaining existing code that already depends on it. If you migrate, wrap image handling in your own service class so the underlying library is easy to swap later.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource