mistralys / application-utils-image
PHP image helper library for basic image operations and color management.
1.1.1
2024-11-14 13:26 UTC
Requires
- php: >=7.4
- ext-gd: *
- mistralys/application-utils-collections: >=1.1
- mistralys/application-utils-core: >=1.0.3
Requires (Dev)
- phpstan/phpstan: >=2.0
- phpunit/phpunit: >=11.4
README
PHP image helper library for basic image editing and color management.
Usage
Create an instance
use AppUtils\ImageHelper; // From a file $helper = ImageHelper::createFromFile('image.jpg'); // From a resource $resource = imagecreatefromjpeg('image.jpg'); $helper = ImageHelper::createFromResource($resource); // New blank image $helper = ImageHelper::createNew(200, 100);
Resize an image
use AppUtils\ImageHelper; ImageHelper::createFromFile('image.jpg') ->resampleByWidth(200) ->save('resized.jpg');
Get image dimensions (including SVG)
use AppUtils\ImageHelper; $size = ImageHelper::createFromFile('image.jpg')->getSize(); echo $size->toReadableString();