1. Go to this page and download the library: Download rundiz/image library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rundiz / image example snippets
$Image = new \Rundiz\Image\Drivers\Gd('/path/to/source-image.jpg');
$Image = new \Rundiz\Image\Drivers\Imagick('/path/to/source-image.jpg');
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');
}
// 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
$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');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.