rundiz / image
Image manipulation use GD or Imagick as drivers. It support watermark image or text, resize, crop, rotate, transparency gif or png and also support animation gif (Imagick only).
3.1.1
2021-12-08 08:04 UTC
Requires
- php: >=5.4.0
README
Image manipulation use GD or Imagick as drivers.
Features:
File extensions supported
- GIF
- JPG (JPEG)
- PNG
- WEBP
*
Functional
- Crop
- Flip (Require PHP 5.5+ for GD driver.)
- Resize (aspect ratio and not)
- Rotate
- Watermark image (including alpha transparency.)
- Watermark text (including alpha transparency.)
- Supported transparent GIF, PNG.
- Supported animated GIF (Imagick only).
Example
Gd driver
$Image = new \Rundiz\Image\Drivers\Gd('/path/to/source-image.jpg'); $Image->resize(900, 600); $Image->save('/path/to/new-file-name.jpg');
Imagick driver
$Image = new \Rundiz\Image\Drivers\Imagick('/path/to/source-image.jpg'); $Image->resize(900, 600); $Image->save('/path/to/new-file-name.jpg');
Fallback drivers
You can use multiple drivers as fallback if it does not support.
if (extension_loaded('imagick') === true) { $Image = new \Rundiz\Image\Drivers\Imagick('/path/to/source-image.jpg'); } else { $Image = new \Rundiz\Image\Drivers\Gd('/path/to/source-image.jpg'); } $Image->rotate('hor'); $Image->crop(500, 500, 'center', 'middle'); $Image->save('/path/to/new-file-name.jpg');
For more details, please look in tests folder or see API doc
Remark:
*
WEBP
There are known bugs that prior PHP 7.0, the transparent PNG or GIF that converted to WEBP will be filled with the background color.