Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nishantshah977/compress-to-webp
Compress your jpg, jpeg, png and convert into webp without losing quality ( depends upon level )in PHP.
https://github.com/nishantshah977/compress-to-webp
compression image-processing seo web-optimization webp
Last synced: about 2 months ago
JSON representation
Compress your jpg, jpeg, png and convert into webp without losing quality ( depends upon level )in PHP.
- Host: GitHub
- URL: https://github.com/nishantshah977/compress-to-webp
- Owner: nishantshah977
- License: gpl-3.0
- Created: 2023-08-15T21:10:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-20T03:13:53.000Z (over 1 year ago)
- Last Synced: 2023-08-20T04:19:52.954Z (over 1 year ago)
- Topics: compression, image-processing, seo, web-optimization, webp
- Language: PHP
- Homepage: https://shahnishant.com.np/how-to-optimize-images-for-seo/
- Size: 425 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# compress-to-webp
Compress your jpg, jpeg, png and convert into webp without losing quality ( depends upon level )in PHP.* **Cup.jpg** is original
* **test/filename_to_convert.webp** is compressed```
$dir,
'file_type' => array(
'image/jpeg',
'image/png',
'image/gif'
)
);$ImgCompressor = new ImgCompressor($setting);
$jw = new ImageToWebp();/* Arguments: 'cup.jpg' - Original image path, 'jpg' - Output format, 5 - Compression level (0-9)
*/
$result = $ImgCompressor->run('cup.jpg', 'jpg', 5);if ($result['status'] === 'success') {
$compressedImageName = $result['data']['compressed']['name'];
/*
Arguments: Compressed image path, Output WebP image path, Quality level (95 in this case)
*/
$jw->convert($dir . '/' . $compressedImageName, $dir.'/'.$file,95);
unlink($dir.'/'.$compressedImageName);
echo "Done";
} else {
echo 'Error: ' . $result['message'];
}?>
```# Thanks to
1. [PHP-Image-Compressor-Class](https://github.com/bachors/PHP-Image-Compressor-Class)
2. [PHP-ImageToWebp](https://github.com/rakibtg/PHP-ImageToWebp)**Stay tuned for full readme.md** or take reference from `index.php` comment