2017 © Pedro Peláez
 

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

image

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

  • Tuesday, January 23, 2018
  • by ve3
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Image manipulation

Simple image manipulation that use GD or Imagick as drivers., (*1)

Features:

File extensions supported

  • AVIF (AVIFS)*
  • 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 alpha transparency or transparent AVIF, GIF, PNG, WEBP.
  • Supported animated GIF, WEBP* (Imagick only).

Latest Stable Version License Total Downloads, (*2)

Tested up to PHP 8.4., (*3)

Example

Drivers

Gd driver

$Image = new \Rundiz\Image\Drivers\Gd('/path/to/source-image.jpg');

Imagick driver

$Image = new \Rundiz\Image\Drivers\Imagick('/path/to/source-image.jpg');

Fallback drivers

You can use multiple drivers as fallback if it does not support., (*4)

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 manipulation methods

// Crop an image
$Image->crop(400, 400, 'center', 'middle');// crop start from center of X and Y
$Image->crop(400, 400, 20, 90);// crop start from X 20 and Y 90

// Resize
$Image->resize(600, 400);
// Resize without aspect ratio
$Image->resizeNoRatio(500, 300);

// Rotate
$Image->rotate();// 90 degree
$Image->rotate(180);
$Image->rotate(270);

// Flip
$Image->rotate('hor');// horizontal
$Image->rotate('vrt');//  vertical
$Image->rotate('horvrt');// both horizontal and vertical

// Watermark image
$Image->watermarkImage('/var/www/image/watermark.png', 'center', 'middle');
$Image->watermarkImage('/var/www/image/watermark.png', 50, 90);// watermark start from X 50 and Y 90

// Watermark text
$Image->watermarkText('hello world', '/var/www/fonts/myfont.ttf', 'center', 'middle', 16);
$Image->watermarkText('hello world', '/var/www/fonts/myfont.ttf', 50, 90, 16);// watermark start from X 50 and Y 90

Multiple image process

$Image = new \Rundiz\Image\Drivers\Gd('/path/to/source-image.jpg');
$Image->resize(900, 600);
$Image->save('/path/to/new-file-name-900x600.jpg');
// Use method clear() to clear all processed data 
// and start new image process with the same image source.
$Image->clear();
$Image->resize(300, 100);
$Image->save('/path/to/new-file-name-300x100.jpg');

For more details, please look in tests folder or see [API doc][1], (*5)


Remark:, (*6)

  • *AVIF
    • PHP and Imagick that use ImageMagick prior 7.0.10-25 doesn't supported open or save AVIF.
      Some older system may be able to save but the file's mime type will not changed.
    • PHP and Imagick (depend on ImageMagick) doesn't supported animated AVIF (AVIFS).
    • PHP all version (last checked 8.3) with GD doesn't supported some kind of AVIF.
    • PHP prior 8.1 with GD doesn't supported AVIF.
  • *WEBP
    • PHP and Imagick that use ImageMagick prior 7.0.8.68 doesn't supported open or save animated WEBP.
    • PHP all version (last checked 8.3) with GD doesn't supported animated WEBP.
    • PHP prior 7.0 with GD (1, 2) doesn't supported open or save transparent WEBP.
    • PHP prior 5.6 with GD doesn't fully supported WEBP and may cause image becomes green. Tested with PHP on Windows.

The Versions

23/01 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

image thumbnail watermark animated gif animation crop image resize image rotate image transparency image

22/04 2016

v3.0

3.0.0.0

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

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

image thumbnail watermark animated gif animation crop image resize image rotate image transparency image