free-open-source / php-image-converter

PHP library to convert between gif, jpeg, png and webp image files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Image Converter

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

About

PHP library to convert between gif, jpeg, png and webp image files

License:MIT License


Languages

Language:PHP 100.0%