hectorprats / php-image-converter
PHP class to convert image formats
v1.0
2021-09-26 02:25 UTC
Requires
- php: ^7.1
- ext-exif: *
- ext-gd: *
Requires (Dev)
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^7.0
This package is not auto-updated.
Last update: 2024-05-20 14:21:43 UTC
README
Version 1.2 beta
PHP library to convert between gif, jpeg, png and webp image files.
Usage
Syntax
echo \ImageConverter\convert(string $from , string $to , int $quality);
Example
<?php include __DIR__ . '/src/php-image-converter.php'; $from = __DIR__ . '/my-image.png'; $to = __DIR__ . '/my-image.webp'; echo \ImageConverter\convert($from, $to);
Quality
The third argument is an optional $quality
value. It will differ depending on your image format.
Format | Default | Min | Max | Description |
---|---|---|---|---|
gif | null |
null |
null |
Quality value not supported |
jpeg | -1 |
0 |
100 |
Higher means better quality |
png | -1 |
0 |
9 |
Lower means better quality |
webp | 80 |
0 |
100 |
Higher means better quality |
Notes
If you try to convert to a path that has not been created, it will try to create it automatically.
Requirements
- PHP 7+
- GD (active on almost every server by default)
Contributors
Contributing
Please see contributing for details.
Inspiration
Donate
Donate to DevoneraAB if you want.
License
MIT