title: Generate thumbnail image from .webp file
body: <p>I am trying to create a simple, single file thumbnail generator.</p>
  
  <p>This file takes the image url and generates a small image.</p>
  
  <p>It works for .JPG, .PNG, .GIF images, <strong>but does not work for .WEBP</strong>.</p>
  
  <h2>Request</h2>
  
  <p>How to make my code also generate the image .WEBP?</p>
  
  <h2>Start</h2>
  
  <blockquote>
    <p>thumb.php?img=./product/image.webp</p>
  </blockquote>
  
  <h2>File: thumb.php</h2>
  
  <pre><code>&lt;?php
    $imagem = $_GET['imagem'];
  
    $extensao = strrchr($imagem, '.');
  
    if($extensao==".gif" or $extensao==".GIF") {
      header("Content-type: image/gif");
    }
  
    if($extensao==".jpg" or $extensao==".JPG") {
      header("Content-type: image/jpeg");
    }
  
    if($extensao==".png" or $extensao==".PNG") {
      header("Content-type: image/png");
    }
  
    if($extensao==".webp" or $extensao==".WEBP") {
      header("Content-type: image/webp");
    }
  
  
  
    $largura = 110;
    $altura = 88;
  
    $imagem = $imagem;
    $max_x = $largura;
    $max_y = $altura;
  
  
  
    if($extensao==".gif" or $extensao==".GIF") {
      $im = imagecreatefromgif($imagem);
    }
  
    if($extensao==".jpg" or $extensao==".JPG"){
      $im = imagecreatefromjpeg($imagem);
    }
  
    if($extensao==".png" or $extensao==".PNG"){
      $im = imagecreatefrompng($imagem);
    }
  
    if($extensao==".webp" or $extensao==".WEBP"){
      $im = imagecreatefromwebp($imagem);
    }
  
  
  
    if ($max_x != 0 &amp;&amp; $max_y != 0) {
      $x = imagesx($im);
      $y = imagesy($im);
  
      if ($x &gt; $max_x) {
        $y = (int)floor($y * ($max_x / $x));
        $x = $max_x;
      }
  
      if ($y &gt; $max_y) {
        $x = (int)floor($x * ($max_y / $y));
        $y = $max_y;
      }
    }
  
  
  
    $img_dest = ImageCreateTrueColor($x, $y);
  
    ImageCopyResampled($img_dest,$im,0,0,0,0,$x,$y,imagesx($im),imagesy($im));
  
  
  
    if($extensao==".jpg" or $extensao==".JPG") {
      imagejpeg($img_dest, $arquivo_miniatura);
    }
  
    if($extensao==".png" or $extensao==".PNG") {
      imagepng($img_dest, $arquivo_miniatura);
    }
  
    if($extensao==".gif" or $extensao==".GIF") {
      imagegif($img_dest, $arquivo_miniatura);
    }
  
    if($extensao==".webp" or $extensao==".WEBP") {
      imagewebp($img_dest, $arquivo_miniatura);
    }
  
  
  
    if($extensao==".jpg" or $extensao==".JPG") {
      imagejpeg($img_dest);
      echo $arquivo_miniatura;
    }
  
    if($extensao==".png" or $extensao==".PNG") {
      imagepng($img_dest);
      echo $arquivo_miniatura;
    }
  
    if($extensao==".gif" or $extensao==".GIF") {
      imagegif($img_dest);
      echo $arquivo_miniatura;
    }
  
    if($extensao==".webp" or $extensao==".WEBP") {
      imagewebp($img_dest);
      echo $arquivo_miniatura;
    }
  
  ?&gt;
  
  
  </code></pre>
  
  <p>Thanks.</p>