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

Laravel 5 Image Manager Laravel Package

anakadote/laravel-5-image-manager

Image management for Laravel 5: a package for handling image uploads, storage, and manipulation in your applications. It integrates with Eloquent models to simplify common image workflows, letting you manage image files and their associated records through a single, convenient interface.

View on GitHub
Deep Wiki
Context7

Getting Started

This package is a thin, Laravel-5-era wrapper around intervention/image. Before you build anything on it, confirm three things in the repo's src/ directory: the service provider class, the facade class/alias, and whether intervention/image is a hard dependency or something you must require yourself.

Minimal setup:

composer require anakadote/laravel-5-image-manager

Register the provider and facade in config/app.php (this predates package auto-discovery):

'providers' => [
    Anakadote\ImageManager\ImageManagerServiceProvider::class,
],

'aliases' => [
    'ImageManager' => Anakadote\ImageManager\Facades\ImageManager::class,
],

Publish and review the config. The file name and keys are the first thing to verify after publishing — likely candidates are upload path, default quality, and driver (GD vs Imagick):

php artisan vendor:publish --provider="Anakadote\ImageManager\ImageManagerServiceProvider"

Make sure the destination directory exists and is writable by PHP (storage/app/public/... or public/uploads/...). Then the first real use case — resize an uploaded avatar in a controller:

public function storeAvatar(Request $request)
{
    $request->validate([
        'avatar' => 'required|image|mimes:jpeg,png|max:2048',
    ]);

    $file = $request->file('avatar');
    $filename = 'avatars/' . uniqid() . '.jpg';

    ImageManager::make($file->getRealPath())
        ->resize(200, 200)
        ->save(public_path($filename));

    return back()->with('path', $filename);
}

Where to look first: the facade's docblock (it usually lists every proxied method), the config file, and the composer.json of the package to see which PHP/Laravel versions and which image driver it actually targets.

Implementation Patterns

Treat it as an Intervention wrapper. The fluent API (make, resize, crop, fit, save, resizeCanvas, rotate, quality) maps onto Intervention\Image\Image, which is what make() and the chained calls return. If a method is missing from the wrapper, the returned image object almost certainly still exposes it — inspect get_class() on the result when unsure.

Generate derivatives in a loop, not one call at a time. Define your sizes as data and iterate; this keeps naming consistent and makes it trivial to add a new size later:

$sizes = ['thumb' => [150, 150], 'medium' => [600, 600], 'full' => [1600, 1600]];
foreach ($sizes as $name => [$w, $h]) {
    ImageManager::make($original)
        ->fit($w, $h)          // or ->resize($w, $h, ...) depending on desired aspect behavior
        ->save(public_path("media/{$name}/{$basename}"));
}

Decide early between resize (may distort) and fit/resizeCanvas (preserves aspect, pads or crops). Mixing them across the codebase produces inconsistent thumbnails.

Store originals, serve derivatives. Keep the uploaded file untouched, write derivatives with a deterministic naming scheme ({id}_{size}.jpg), and persist only the base name on the model. Accessors then build URLs:

public function getThumbUrlAttribute()
{
    return asset("media/thumb/{$this->image_basename}.jpg");
}

Push heavy work to a queue. Don't resize ten variants inside the HTTP request for large uploads. Pass the file path (string) to the job, not the image object — the Intervention image can't be serialized. Delete the temp original in the job's finally block.

Clean up on delete. Register a model observer or deleting hook that removes all derivative files. Orphaned derivatives are the most common long-term problem with image pipelines.

Funnel all image writes through one service. Wrap the facade in a small ImageService of your own so that if/when you replace this package with raw intervention/image (see Gotchas), you change one file instead of every controller.

Validate before you touch PHP's image functions. Always use image|mimes:jpeg,png|max:... and never derive the extension from the user-supplied filename. Re-encode rather than copying the upload verbatim if you're worried about embedded payloads.

Gotchas and Tips

This is Laravel 5 only. The package has ~14 stars and zero dependents, so assume no maintenance. It targets Laravel 5 APIs and will not install cleanly on Laravel 6+ without forking (composer require will fail on constraint conflicts). If you're on a modern Laravel, skip this package and use intervention/image directly — the wrapper adds almost nothing you can't replicate in twenty lines.

Confirm the GD/Imagick driver. If make() fails silently or throws on load, check php -m | grep -E 'gd|imagick' and your php.ini memory_limit. Resizing a 12MP photo through GD routinely hits 128M; 256M+ is safer.

EXIF orientation is not applied by default. Phone photos will come out rotated. Either apply ->orientate() (Intervention exposes it) before resizing, or strip orientation by re-encoding — do not trust that the wrapper handles it.

Path resolution is the #1 source of "it saved nowhere" bugs. save() takes a filesystem path, not a URL and not a Laravel disk. public_path(), storage_path(), and base_path() behave differently under symlinked deploys. Log realpath(dirname($target)) once if a save appears to succeed but nothing lands.

Config caching can hide your changes. After editing the published config on a cached install, run php artisan config:clear. The same applies if you moved the upload directory via env.

Watch save()'s return value. Some versions of this era return false on failure rather than throwing. Wrap saves in a check or try/catch and assert the file exists in tests.

Quality vs. size. Default JPEG quality in these wrappers is often 90; dropping to 75–80 for thumbnails cuts bytes substantially with no visible difference at small sizes.

Extension points are limited. The realistic extension options are (a) subclass the manager and rebind it in the container, or (b) bypass the facade entirely and inject Intervention\Image\ImageManager. Because the package is unmaintained, (b) is usually the better long-term choice — vendor the wrapper's two or three useful methods into your own service and drop the dependency when you next upgrade Laravel.

Debugging checklist when a resize fails: confirm the source path exists and is readable, confirm the driver extension is loaded, confirm the destination directory exists (the wrapper may not create it), check storage/logs/laravel.log for the underlying Intervention exception, and test the same call in php artisan tinker to isolate it from request handling.

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.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle