1. Go to this page and download the library: Download ibrahim-kaya/imageman library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ibrahim-kaya / imageman example snippets
use IbrahimKaya\ImageMan\ImageManFacade as ImageMan;
// From an HTTP request field
$image = ImageMan::upload($request->file('photo'))->save();
// From a remote URL
$image = ImageMan::uploadFromUrl('https://example.com/photo.jpg')->save();
echo $image->url('medium'); // Public URL for the medium variant
echo $image->url('thumbnail'); // Public URL for the thumbnail
echo $image->url(); // Main image URL
$image = ImageMan::find(1); // Returns ?Image
$image = ImageMan::get(1); // Returns Image or throws ImageNotFoundException
ImageMan::destroy(1); // Deletes DB record + disk files
$image->delete(); // Same, called on the model instance
// Basic
$image = ImageMan::uploadFromUrl('https://example.com/photo.jpg')->save();
// Full fluent chain — all options available
$image = ImageMan::uploadFromUrl('https://cdn.example.com/banner.png', timeoutSeconds: 60)
->disk('s3')
->collection('remote')
->sizes(['thumbnail', 'medium', 'large'])
->format('avif')
->watermark()
->meta(['alt' => 'Remote banner'])
->save();
// Via HasImages trait — just pass the URL string instead of an UploadedFile
$post->uploadImage('https://example.com/photo.jpg', 'gallery');
$user->uploadImage('https://example.com/avatar.png', 'avatars', ['disk' => 's3', 'timeout' => 45]);
use IbrahimKaya\ImageMan\Exceptions\UrlFetchException;
try {
$image = ImageMan::uploadFromUrl($url)->save();
} catch (UrlFetchException $e) {
// URL not reachable, non-2xx response, or response is not an image
Log::error('Remote image download failed', ['url' => $url, 'reason' => $e->getMessage()]);
}
// Upload to S3
$image = ImageMan::upload($file)->disk('s3')->save();
// Upload to FTP
$image = ImageMan::upload($file)->disk('ftp')->save();
// Default disk override for the next upload only
ImageMan::disk('s3')->upload($file)->save();
// Enable for this upload only (uses config path/text)
$image = ImageMan::upload($file)->watermark()->save();
// Disable for this upload only (even if config has enabled: true)
$image = ImageMan::upload($file)->noWatermark()->save();
// First upload
$user->uploadImage($request->file('photo'), 'profile_pic');
// Second upload — first image is automatically deleted after this saves
$user->uploadImage($request->file('photo'), 'profile_pic');
// Explicit replace
$user->uploadImage($file, 'profile_pic', ['replace' => true]);
// Explicit keep (even if profile_pic is in singleton_collections config)
$user->uploadImage($file, 'profile_pic', ['replace' => false]);
// profile_pic is in singleton_collections but we want to keep both this time
$image = ImageMan::upload($file)
->for($user)
->collection('profile_pic')
->keepExisting()
->save();
use IbrahimKaya\ImageMan\Resources\ImageResource;
// Single image
return ImageResource::make($image);
// Collection
return ImageResource::collection(Image::all());
use IbrahimKaya\ImageMan\Integrations\Filament\FilamentImageManPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugin(FilamentImageManPlugin::make());
}
use IbrahimKaya\ImageMan\Integrations\Filament\Forms\ImageManUpload;
ImageManUpload::make('photo')
->collection('avatars')
->disk('s3')
->sizes(['thumbnail', 'medium'])
use IbrahimKaya\ImageMan\Integrations\Filament\Tables\ImageManColumn;
ImageManColumn::make('photo')
->collection('avatars')
->size('thumbnail')
->circular()
use IbrahimKaya\ImageMan\Integrations\Nova\ImageManField;
public function fields(NovaRequest $request): array
{
return [
ImageManField::make('Photo')
->collection('avatars')
->disk('s3')
->size('medium'),
];
}
bash
php artisan imageman:regenerate
php artisan imageman:regenerate --size=hero # Only the 'hero' preset
php artisan imageman:regenerate --collection=gallery # Only gallery images
php artisan imageman:regenerate --disk=s3 # Only S3 images
bash
php artisan imageman:clean # With confirmation prompt
php artisan imageman:clean --dry-run # Preview only (no deletions)
php artisan imageman:clean --older-than=30 # Only images older than 30 days