Open Source PHP API to Manipulate Images
PHP Library that enables Software programmers to resize, sharp, merge, colorize, fill and rotate images.
The Gregwar's Image is an open source object-oriented library that gives software developers the capability to manipulate images inside their own PHP applications. Using the API, you can resize, scale resize, force resize, crop resize, zoom crop, crop and negate images. Furthermore, the API also allows you to set brightness, contrast, convert the image to greyscale, emboss the image, smooth the image, sharpen image, colorize the image, and more.
The API never applies a feature on an opened image. Instead - The API first caches all the images and then applies the features. The API adds the image in the operations array consisting of name, type and you can use the hash to look up for the file in the cache.
Getting Started with Gregwar's Image
It requires PHP 5.2+. You can easily install the Gregwar's Image library via composer. Please use the following command.
Install Gregwar's Image via Composer
{
...
"require": {
"gregwar/image": "2.*"
}
}
Resize Images via Free PHP API
The open source Gregwar's Image library has provided support for resizing images inside applications. Using the API, the developer can simply import the Gregwar library, open the image, resize it and save it. The resizing process is pretty simple and only requires one line of code. You can open it with open() method and resize it using resize() method.
Resize Image in PHP
- Import Library
- Open Image and pass image file path, resize it and provide output image size width and height.
- Negate the image colors and save the image
Resize Image via Free PHP API
Image::open('fileformat.png')
->resize(100, 100)
->negate()
->save('output.jpg');
Rotate, Flip & Apply Effects to Images via PHP
The open source Gregwar's Image library has included several important features for image handling and manipulation inside PHP applications. The library gives software developers the capability to flip, crop, or rotate their images using PHP commands. It supports features for resizing the image preserving scale, resizing and cropping the image to fit given dimensions, changing the position of the resized image, negating the image colors, converting the image to grayscale, embossing the image, merging files, adding watermark to image, applies an edge effect on the image and many more.
Merge Images via Free PHP API
require_once '../autoload.php';
use Gregwar\Image\Image;
Image::open('img/test.png')
->merge(Image::open('img/test2.jpg')->cropResize(100, 100))
->save('out.jpg', 'jpg');
Apply Watermark to Image via Free PHP API
require_once '../autoload.php';
use Gregwar\Image\Image;
// Opening mona.jpg
$img = Image::open('img/mona.jpg');
// Opening vinci.png
$watermark = Image::open('img/vinci.png');
// Mergine vinci text into mona in the top-right corner
$img->merge($watermark, $img->width()-$watermark->width(),
$img->height()-$watermark->height())
->save('out.jpg', 'jpg');