hectorprats / php-image-converter
PHP class to convert image formats
Installs: 22
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 24
pkg:composer/hectorprats/php-image-converter
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: 2026-01-12 22:26:29 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