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.0 2021-07-29 08:42 UTC

This package is auto-updated.

Last update: 2021-09-29 09:21:19 UTC


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).

Latest Stable Version License Total Downloads

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.