Wrong in an envelope in a .png, why does the pope think the file is...webp is incorrect?



  • I'm trying to get a reference file in a new one-time format and keep it in ping format. http://sdev.ml/1.webp

    This is the code that works with other files correctly, and with this file or other photos from the Google Plaimarec is making a mistake.

    // Load the WebP file
    $im = imagecreatefromwebp('http://sdev.ml/1.webp');
    

    // Convert it to a jpeg file with 100% quality
    imagejpeg($im, 'example.jpeg', 100);
    imagedestroy($im);

    But I get the following mistakes:

     Warning: imagecreatefromwebp(): WebP decode: fail to decode input data in W:\domains\gpget.ru\index.php on line 107

    Warning: imagecreatefromwebp(): 'http://sdev.ml/1.webp' is not a valid WEBP file in W:\domains\gpget.ru\index.php on line 107

    Warning: imagejpeg() expects parameter 1 to be resource, boolean given in W:\domains\gpget.ru\index.php on line 110

    Warning: imagedestroy() expects parameter 1 to be resource, boolean given in W:\domains\gpget.ru\index.php on line 111



  • Yes, correctly noted in the comments on libwebp, libgd, We need to check their version and compatibility with your PHP.

    It's a mistake that the file isn't valid.

    Actually, you can't trust the expansion of the file by looking at the url.

    The pictures may not be webp a png

    Read the mime file and then switch the appropriate imagecreate from. ♪ ♪ (grunts)

    $finfo = new finfo(FILEINFO_MIME);
    echo $finfo->buffer('http://sdev.ml/1.webp');
    

    In your case, mime = text/plain; charset=us-ascii

    Should have been my application/webp


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2