Конвертируйте jpg в webp с помощью imagewebpPhp

Кемеровские программисты php общаются здесь
Гость
Конвертируйте jpg в webp с помощью imagewebp

Сообщение Гость »


I'm having trouble using imagewebp to convert an image to webp.

I use this code:

$filename = dirname(__FILE__) .'/example.jpg'; $im = imagecreatefromjpeg($filename); $webp =imagewebp($im, str_replace('jpg', 'webp', $filename)); imagedestroy($im); var_dump($webp); $webp returns true but when I try to view the webp-image in Chrome it just shows blank, but with the correct size. If I instead load the image and set headers with PHP (see below) it shows up, but with wrong colors (too much yellow).

$im = imagecreatefromwebp('example.webp'); header('Content-Type: image/webp'); imagewebp($im); imagedestroy($im); If I convert the same image with command line it works as expected.

cwebp -q 100 example.jpg -o example.webp I'm testing this on Ubuntu 14, Apache 2.4.7 and PHP 5.5.9-1ubuntu4.4.


Источник: https://stackoverflow.com/questions/263 ... -imagewebp

Вернуться в «Php»