Skip to content

xp-framework/imaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Imaging APIs for the XP Framework

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.4+ Supports PHP 8.0+ Latest Stable Version

Loading an image

use img\Image;
use img\io\JpegStreamReader;
use io\File;

$image= Image::loadFrom(new JpegStreamReader(new File('image.jpeg')));

// Can now be manipulated

Manipulating an image

Resizing the original image to 640x480

use img\Image;

$transformed= Image::create(640, 480, Image::TRUECOLOR);
$transformed->resampleFrom($image);

Apply filters:

use img\filters\SharpenFilter;

$transformed->apply(new SharpenFilter());

Convert:

use img\convert\GrayscaleConverter;

$transformed->convertTo(new GrayscaleConverter());

Saving an image

use img\io\JpegStreamWriter;
use io\File;

$transformed->saveTo(new JpegStreamWriter(new File('transformed.jpeg'), 100));