Version 1.2 beta
PHP library to convert between gif, jpeg, png and webp image files.
echo \ImageConverter\convert(string $from , string $to , int $quality);
<?php
include __DIR__ . '/src/php-image-converter.php';
$from = __DIR__ . '/my-image.png';
$to = __DIR__ . '/my-image.webp';
echo \ImageConverter\convert($from, $to);
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 |
If you try to convert to a path that has not been created, it will try to create it automatically.
- PHP 7+
- GD (active on almost every server by default)
Please see contributing for details.
Donate to DevoneraAB if you want.
MIT