Download the PHP package povly/moonshine-intervention-image without Composer
On this page you can find all versions of the php package povly/moonshine-intervention-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download povly/moonshine-intervention-image
More information about povly/moonshine-intervention-image
Files in povly/moonshine-intervention-image
Package moonshine-intervention-image
Short Description Image optimization and WebP/AVIF conversion field for MoonShine using intervention/image
License MIT
Informations about the package moonshine-intervention-image
MoonShine Intervention Image Field
⚠️ This package is no longer maintained.
Use these two packages instead:
- yurizoom/moonshine-media-manager — file manager
- povly/moonshine-image-editor — visual image editor with optimization and WebP/AVIF conversion
Image optimization and WebP/AVIF conversion field for MoonShine using intervention/image.
Installation
The package requires intervention/image and intervention/image-laravel. If not already installed:
Publish the config (optional):
Requirements
- PHP 8.2+
- Laravel 11+ / 12+
- MoonShine 4.x
- intervention/image ^3.0
- intervention/image-laravel ^1.0
- GD or Imagick extension
Configuration
Publish the config file to customize default settings:
Basic Usage
Watermark
Available Positions
| Position | Description |
|---|---|
top-left |
Top left corner |
top |
Top center |
top-right |
Top right corner |
left |
Left center |
center |
Center |
right |
Right center |
bottom-left |
Bottom left corner |
bottom |
Bottom center |
bottom-right |
Bottom right corner (default) |
custom |
Custom X/Y coordinates |
Image Watermark
Text Watermark
Disable Watermark Per Field
Global Watermark via Config
Configure watermarks globally for all images:
Or via .env:
Offset Behavior
| Offsets work relative to the position: | Position | offset_x positive |
offset_y positive |
|---|---|---|---|
top-left |
Moves right | Moves down | |
top |
Moves right | Moves down | |
top-right |
Moves left | Moves down | |
left |
Moves right | Moves down | |
center |
Moves right | Moves down | |
right |
Moves left | Moves down | |
bottom-left |
Moves right | Moves up | |
bottom |
Moves right | Moves up | |
bottom-right |
Moves left | Moves up |
Example - move watermark away from edges:
Queue Processing
Process images in the background using Laravel queues. Useful for handling large images or multiple uploads without blocking the user request.
Enable via Config
Enable via Field Method
Queue Job
The ProcessImage job handles:
- Image optimization
- WebP conversion
- AVIF conversion
- Watermarks (image and text)
- Automatic retries (3 attempts by default)
- 1 hour retry window
- Exponential backoff (10s, 30s, 60s)
Optimize Command
The moonshine:image:optimize Artisan command allows you to batch-optimize existing images. It scans a storage disk (or specific paths), applies optimization, and optionally generates WebP/AVIF conversions — using settings from your config.
Basic Usage
Queue vs Sync
By default, the command reads moonshine-intervention-image.queue.enabled from config. Override with flags:
Apply a Preset
Override Options
All processing options can be overridden per run:
Combined Example
Config
exclude_paths is an array of directory paths that will be skipped during full-disk scans:
Command Options
| Option | Description |
|---|---|
paths |
Specific file or directory paths to optimize (positional, optional) |
--disk= |
Storage disk to scan (default: from config) |
--preset= |
Apply a named preset from config |
--queue |
Force queue processing |
--sync |
Force synchronous processing |
--quality= |
Override quality for original image (1-100) |
--quality-webp= |
Override quality for WebP (1-100) |
--quality-avif= |
Override quality for AVIF (1-100) |
--generate-webp |
Generate WebP versions |
--no-webp |
Disable WebP generation |
--generate-avif |
Generate AVIF versions |
--no-avif |
Disable AVIF generation |
--strip-metadata |
Strip EXIF/IPTC metadata |
--max-width= |
Maximum image width (keeps aspect ratio) |
--max-height= |
Maximum image height (keeps aspect ratio) |
Methods
| Method | Description |
|---|---|
preset(string $name) |
Apply preset from config |
generateWebp(bool $generate = true) |
Generate WebP version of the image |
generateAvif(bool $generate = true) |
Generate AVIF version of the image |
quality(int $quality) |
Set quality for original image (1-100, default: 85) |
qualityWebp(int $quality) |
Set quality for WebP (1-100, default: 80) |
qualityAvif(int $quality) |
Set quality for AVIF (1-100, default: 65) |
pngIndexed(bool $indexed = true, int $colors) |
Optimize PNG with indexed colors (default: 256) |
stripMetadata(bool $strip = true) |
Strip EXIF/IPTC metadata from images |
maxDimensions(?int $width, ?int $height = null) |
Resize images while keeping aspect ratio |
watermarkImage(...) |
Add image watermark |
watermarkText(...) |
Add text watermark |
watermarkTextFont(?string $fontPath) |
Set font for text watermark |
watermarkTextStroke(?string $color, int $width) |
Add stroke to text watermark |
watermarkTextAngle(?int $angle) |
Rotate text watermark |
disableWatermark(bool $disable = true) |
Disable watermark for this field |
queue(bool $enabled, ?string $connection, ?string $queue, $delay) |
Enable queue processing |
queueDelay(...) |
Set queue delay |
logging(bool $enabled = true) |
Enable logging (disabled by default) |
PNG Optimization
PNG is a lossless format, so the quality parameter doesn't reduce file size. To optimize PNG files, use the pngIndexed() method which converts the image to use a palette of indexed colors (like GIF):
This can significantly reduce PNG file size, especially for images with limited colors.
AVIF Support
AVIF provides superior compression compared to WebP and JPEG. Use qualityAvif() to control the quality:
Recommended AVIF quality values:
- 50-60: Maximum compression, acceptable quality for thumbnails
- 60-70: Good balance between size and quality (default: 65)
- 70-80: High quality, still smaller than WebP/JPEG
Note: AVIF requires Imagick or GD with AVIF support compiled in.
Logging
Enable logging to debug and monitor image processing:
Logs will appear in storage/logs/laravel.log with [InterventionImage] prefix:
Complete Examples
1. Simple Usage (without layouts-field)
For single and multiple images without the moonshine/layouts-field package.
Layout
Add the removeImage JavaScript function to your MoonShine layout:
Model
Resource
FormPage
2. Usage with layouts-field
When using moonshine/layouts-field package for flexible content blocks.
Layout
Add the removeImage and removeLayoutImage JavaScript functions to your MoonShine layout:
Model
Migration
Resource
FormPage
Supported Formats
- JPEG / JPG
- PNG
- GIF
- WebP
- AVIF
Documentation
For actual files, configuration options, and the latest information about the required packages, please refer to their official documentation:
- intervention/image
- MoonShine
- moonshine/layouts-field
Package APIs and configurations may change over time, so always check the current documentation.
License
MIT
All versions of moonshine-intervention-image with dependencies
intervention/image Version ^3.0
intervention/image-laravel Version ^1.0
moonshine/moonshine Version ^4.0