toropyga / fimages
Libraries for working with images from Toropyga
Requires
- php: >=5.1.0
- ext-gd: >=2.0.18
- ext-mbstring: *
README
Image processing class
Table of Contents
General Concepts
The FImages class is designed for editing images and generating captchas. To use it, you need PHP 5 or higher and the GD library.
Features of the FImages Class
The FImages class allows you to edit existing images and images passed in as strings.
It can resize images to the specified dimensions either proportionally or by cropping.
It can create an image filled with the source image, stretched to the requested aspect ratio.
It can add text to an image.
It can rotate an image around its axis and also mirror it.
It can generate and display a captcha and much more.
Examples
Basic class parameters
$TYPE - create as $TYPE = 'GIF'; $TYPE = 'JPEG'; //$TYPE = 'JPG'; $TYPE = 'PNG'; $TYPE = 'WEBP'; $path - Path to image; $dpath - Path to save; $name - new image name; $w - end width; $h - end height; $img - string of image $save - result handling (where and how to save/output the file) $save = 1 // replace old image and return this file as a string $save = 2 // print new image $save = 3 // return new file as a string $save != 1 or 2 or 3 // return a descriptor of the new file
Usage
Crop an image to the specified dimensions
include ("FImages.php"); $IMG = new FImages($TYPE, $w, $h); $IMG->cut($path, $save);
Crop an image to the specified dimensions and return it as a string
include ("FImages.php"); $IMG = new FImages($TYPE, $w, $h); $image = $IMG->cut($path);
Stretch an image to the specified aspect ratio
include ("FImages.php"); $IMG = new FImages(); $IMG->resize($path, $save, $w, $h);
Resize an image proportionally
include ("FImages.php"); $IMG = new FImages(); $IMG->resize_pro($path, $save, $w, $h); # proportion resize
Create an image filled with the source image
$IMG->fill($path, $save, $w, $h); # fill background
Create a temporary file from the source and get its data
$IMG->getTempFile($img, $function, $save, $w, $h);
Create an image copy
include ("FImages.php"); $IMG = new FImages('JPG', 40, 40); $ds = $IMG->resize($path); $IMG->createImgCopy($ds, $dpath, $name);
Generate a captcha
<img src='".$IMG->captcha(false)."'> or $IMG->captcha();
Return captcha characters for validation
$IMG->getKeyString(); // captcha in string