Download the PHP package ayvazyan10/nova-imagic without Composer
On this page you can find all versions of the php package ayvazyan10/nova-imagic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ayvazyan10/nova-imagic
More information about ayvazyan10/nova-imagic
Files in ayvazyan10/nova-imagic
Package nova-imagic
Short Description Imagic is a Laravel Nova field package that allows for image manipulation capabilities, such as cropping, resizing, quality adjustment, and WebP conversion. It utilizes the powerful Intervention Image class for image manipulation.
License MIT
Informations about the package nova-imagic
Imagic for Laravel Nova 4
Imagic is a Laravel Nova field package that allows for image manipulation capabilities, such as cropping, resizing, quality adjustment, and WebP conversion. It utilizes the powerful Intervention Image class for image manipulation. The purpose of this package is to optimize images for web usage by converting them to the WebP format, which provides superior compression and faster load times.
Advanced Image Manipulation Made Easy with Images Magic
✅ Single/Multiple Uploads
✅ Cropping
✅ Resizing
✅ Fitting
✅ Quality Control
✅ WebP Conversion
✅ Watermarking
✅ Custom Directories
Requirements
- PHP (^7.1 or higher)
- Laravel Nova (^4.0 or higher)
🚀 Installation
Install the package via Composer.
`
📚 Usage
Here is an example of how to use Imagic in your Laravel Nova application: In your Laravel Nova resources, use the Imagic field: `
⚡ All Methods
`
📖 Examples
Below are some examples in different scenarios.
- Multiple Images
To enable multiple image uploads, use the multiple() method. Note that when you use the multiple() method, your database column should be of type text, longtext, or json to store all images in a JSON format. Additionally, you will have the ability to sort uploaded images by drag and drop.
- Cropping
To crop images, use the crop() method:
- x (optional) X-Coordinate of the top-left corner if the rectangular cutout. By default the rectangular part will be centered on the current image.
- y (optional) Y-Coordinate of the top-left corner if the rectangular cutout. By default the rectangular part will be centered on the current image.
- Resizing
To resize images, use the resize() method:
- Widen resizing by width
Specify the desired (only - width) for image resizing.
- The height will be automatically adjusted to maintain the aspect ratio.
- Quality
To adjust the image quality, use the quality() method: default is 90
- WebP Conversion
To convert images to WebP format, use the convert() method:
By default, the images will be converted to WebP format. To disable conversion, pass false to the convert() method:
- Fit
You can use the fit() method when defining the Imagic field in your Nova resource:
- Field with watermark
Replace the /path/to/watermark.png with the actual path to your watermark image.
This will add the watermark to the image with the specified path, position, and offset (15x15 pixels from the bottom-right corner in this example).
Remember to import the Imagic class at the top of your Nova resource file:
- Specified disk
Here is an example of how to use it:
Caution: The disk is not working with custom directories and will throw an error.
- Directory Customization
BY DEFAULT - Imagic uses this structure: /storage/imagic/year/month/day/image_name.webp
The Imagic class includes a directory() method that allows you to specify a custom directory path for your image uploads. This allows for more flexibility in managing the location of your image files.
To use this feature, call the directory() method when creating an Imagic field and provide it with your custom directory path as an argument. This path should be a string, and should not start or end with a /.
Here is an example of how to use it:
In this example, any images uploaded through this field will be saved in your/custom/directory.
Caution: The provided directory path should not start or end with a /. If it does, an InvalidArgumentException will be thrown. Make sure your directory path is correctly formatted when using this feature.
For example, the following code would throw an exception:
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Author
License
MIT. Please see the license file for more information.