{"id":36315256,"url":"https://github.com/joshembling/image-optimizer","last_synced_at":"2026-01-11T11:01:28.576Z","repository":{"id":195340714,"uuid":"692730193","full_name":"joshembling/image-optimizer","owner":"joshembling","description":"🎨 Optimize your Filament images before they reach your database.","archived":false,"fork":false,"pushed_at":"2025-10-19T21:20:05.000Z","size":213,"stargazers_count":109,"open_issues_count":0,"forks_count":32,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-10-20T03:52:21.371Z","etag":null,"topics":["filament","filament-plugin","filamentphp","image","laravel","optimization"],"latest_commit_sha":null,"homepage":"https://filamentphp.com/plugins/joshembling-image-optimizer","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshembling.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"joshembling"}},"created_at":"2023-09-17T12:10:20.000Z","updated_at":"2025-10-19T21:19:39.000Z","dependencies_parsed_at":"2023-09-27T19:44:51.405Z","dependency_job_id":"8d9d0248-d2e6-4d6d-bdbf-339ddbb4bcf1","html_url":"https://github.com/joshembling/image-optimizer","commit_stats":null,"previous_names":["joshembling/filament-image-optimizer","joshembling/image-optimizer"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/joshembling/image-optimizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshembling%2Fimage-optimizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshembling%2Fimage-optimizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshembling%2Fimage-optimizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshembling%2Fimage-optimizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshembling","download_url":"https://codeload.github.com/joshembling/image-optimizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshembling%2Fimage-optimizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28301278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T08:21:30.231Z","status":"ssl_error","status_checked_at":"2026-01-11T08:21:26.882Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filament","filament-plugin","filamentphp","image","laravel","optimization"],"created_at":"2026-01-11T11:01:12.941Z","updated_at":"2026-01-11T11:01:28.562Z","avatar_url":"https://github.com/joshembling.png","language":"PHP","funding_links":["https://github.com/sponsors/joshembling"],"categories":[],"sub_categories":[],"readme":"\u003e [!CAUTION]  \n\u003e There are no plans to extend this plugin's lifetime beyond Filament v3. Please do not plan to use this in production if you are using or upgrading to Filament v4.\n\n# Optimize your Filament images before they reach your database.\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/joshembling/image-optimizer.svg?style=flat-square)](https://packagist.org/packages/joshembling/image-optimizer)\n[![Total Downloads](https://img.shields.io/packagist/dt/joshembling/image-optimizer.svg?style=flat-square)](https://packagist.org/packages/joshembling/image-optimizer)\n\nWhen you currently upload an image using the native Filament component `FileUpload`, the original file is saved without any compression or conversion.\n\nAdditionally, if you upload an image and use conversions with `SpatieMediaLibraryFileUpload`, the original file is saved with its corresponding versions provided on your model. \n\nWhat if you'd rather convert and reduce the image(s) before reaching your database/S3 bucket? Especially in the case where you know you'll never need to save the original image sizes the user has uploaded.\n\n🤳 **This is where Filament Image Optimizer comes in**. \n\nYou use the same components as you have been doing and have access to two additional methods for maximum optimization, saving you a lot of disk space in the process. 🎉\n\n## Contents\n\n- [Contents](#contents)\n- [Installation](#installation)\n- [Usage](#usage)\n\t- [Optimizing Images](#optimizing-images)\n\t- [Resizing Images](#resizing-images)\n\t- [Combining Methods](#combining-methods)\n\t- [Multiple Images](#multiple-images)\n\t- [Examples](#examples)\n\t- [Debugging](#debugging)\n- [Changelog](#changelog)\n- [Contributing](#contributing)\n- [Security Vulnerabilities](#security-vulnerabilities)\n- [Credits](#credits)\n- [Licence](#license)\n\n## Installation\n\nYou can install the package via composer, which currently works with the latest Filament version (^3.2) and Laravel 10, 11 \u0026 12:\n\n```bash\ncomposer require joshembling/image-optimizer\n```\n\nIf you are using Filament 3.0 or 3.1 install with: \n```bash\ncomposer require joshembling/image-optimizer:v1.2\n```\n\n## Usage\n\n### Filament version\n\nYou must be using [Filament v3.x](https://filamentphp.com/docs/3.x/panels/installation) to have access to this plugin.\n\nFor specific versions that match your PHP, Laravel, Filament and Image Optimizer installations please see the table below:\n\n| PHP | Laravel version | Filament version | Image Optimizer version |\n| ----- | ----- | -----| ----- |\n| ^8.1 | ^10.0 | ^3.0 | 1.2 |\n| ^8.1 | ^10.0 | ^3.1 | 1.2 |\n| ^8.1 | ^10.0 | ^3.2 | ~1.3 |\n| ^8.2 | ^10.0, ^11.0 | ^3.2 | ^1.4 |\n| ^8.2 | ^10.0, ^11.0, ^12.0 | ^3.2 | ^1.6 |\n\n### Server\n\n[GD Library](https://www.php.net/manual/en/image.installation.php) must be installed on your server to compress images.\n\n### Optimizing images\n\nBefore uploading your image, you may choose to optimize it by converting to your chosen format. The file saved to your disk will be the converted version only.\n\nE.g. I want to convert my image to 'webp': \n\n`````php\nuse Filament\\Forms\\Components\\FileUpload;\n\nFileUpload::make('attachment')\n    -\u003eimage()\n    -\u003eoptimize('webp'),\n`````\n\nYou can do exactly the same using `SpatieMediaLibraryFileUpload`:\n\n`````php\nuse Filament\\Forms\\Components\\SpatieMediaLibraryFileUpload;\n\nSpatieMediaLibraryFileUpload::make('attachment')\n    -\u003eimage()\n    -\u003eoptimize('webp'),\n`````\n\n### Resizing images\n\nYou may also want to resize an image by passing in a percentage you would like to reduce the image by. This will also maintain aspect ratio.\n\nE.g. I'd like to reduce my image (1280px x 720px) by 50%:\n\n`````php\nuse Filament\\Forms\\Components\\FileUpload;\n\nFileUpload::make('attachment')\n    -\u003eimage()\n    -\u003eresize(50),\n`````\n\nUploaded image size is 640px x 360px.\n\nYou can do the same using `SpatieMediaLibraryFileUpload`:\n\n`````php\nuse Filament\\Forms\\Components\\SpatieMediaLibraryFileUpload;\n\nSpatieMediaLibraryFileUpload::make('attachment')\n    -\u003eimage()\n    -\u003eresize(50),\n`````\n\n### Add maximum width and/or height\n\nYou can also add a maximum width and/or height to the image. This will resize the image to the maximum width and/or height, maintaining the aspect ratio.\n\n`````php\nuse Filament\\Forms\\Components\\FileUpload;\n\nFileUpload::make('attachment')\n    -\u003eimage()\n    -\u003emaxImageWidth(1024)\n    -\u003emaxImageHeight(768),\n`````\n\n### Combining methods\n\nYou can combine these two methods for maximum optimization.\n\n`````php\nuse Filament\\Forms\\Components\\FileUpload;\n\nFileUpload::make('attachment')\n\t-\u003eimage()\n\t-\u003eoptimize('webp')\n\t-\u003emaxImageWidth(1024)\n\t-\u003emaxImageHeight(768)\n\t-\u003eresize(50),\n`````\n\n`````php\nuse Filament\\Forms\\Components\\SpatieMediaLibraryFileUpload;\n\nSpatieMediaLibraryFileUpload::make('attachment')\n    -\u003eimage()\n\t-\u003eoptimize('webp')\n\t-\u003emaxImageWidth(1024)\n\t-\u003emaxImageHeight(768)\n    -\u003eresize(50),\n`````\n\n### Multiple images\n\nYou can also do this with multiple images - all images will be converted to the same format and reduced with the same percentage passed in. Just chain on `multiple()` to your upload:\n\n`````php\nuse Filament\\Forms\\Components\\FileUpload;\n\nFileUpload::make('attachment')\n    -\u003eimage()\n\t-\u003emultiple()\n\t-\u003eoptimize('jpg')\n    -\u003eresize(50),\n`````\n\n`````php\nuse Filament\\Forms\\Components\\SpatieMediaLibraryFileUpload;\n\nSpatieMediaLibraryFileUpload::make('attachment')\n    -\u003eimage()\n\t-\u003emultiple()\n\t-\u003eoptimize('jpg')\n    -\u003eresize(50),\n`````\n\n### Examples \n\n![Before](images/before.jpg) \n\n![After](images/after.jpg)\n\n### Debugging\n\n- If you see a 'not found' exception, including \"Method `optimize`\" or \"Method `resize`\", ensure you run `composer update` so that your lock file is in sync with your `composer.json`. \n\n- You might see a 'Waiting for size' message and an infinite loading state on the component and the likely cause of this is a CORS issue. This can be quickly be resolved by ensuring you are serving and upload images from the same domain. Check your Javascript console for more information.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Josh Embling](https://github.com/joshembling)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshembling%2Fimage-optimizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshembling%2Fimage-optimizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshembling%2Fimage-optimizer/lists"}