xp-framework/imaging

Imaging APIs for the XP Framework

v11.0.0 2024-03-29 11:49 UTC

README

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