vendredi 8 mai 2015

imagewebp (php) creates corrupted webp files

Recently I've been fiddling with the WebP image format. I use php 5.5.12 for this, with the gd library installed (gd 2.1.0 / webp supported). I noticed that for some reason, PHP creates corrupted webp-images. The code I used is the following:

$im= imagecreatefromjpeg("test_img.jpg");
$succes = imagewebp($im, "test_img.webp");
if ($im !== false && $succes == true) {
    echo "Succes.";
}

I fail to grasp why the webp image written to the filesystem by this php script is corrupt. For your convenience, I have attached one of the test images. After processing, its associated webp image is indeed a corrupt image on my system. I'd appreciate your input on this, as I have no idea why this does not work properly.

Initially, I hoped that the problem might be in the stuffing of a wrong byte somewhere in the file, but comparing a proper webp image rendered from this JPEG file to the faulty one, I noticed such stark dissimilarities that I doubt the problem is due to a faulty stuffed byte.

Image: http://ift.tt/1AKvo5M (JPEG)

Aucun commentaire:

Enregistrer un commentaire