$tnhaut) { $convert = $tnhaut/$height; $height = $tnhaut; $width = ceil($width*$convert); } if ($width > $tnlarge) { $convert = $tnlarge/$width; $width = $tnlarge; $height = ceil($height*$convert); } $largeur = $width; $hauteur = $height; if($type == 1) { $img_in = imagecreatefromgif($img); } elseif($type == 2) { $img_in = imagecreatefromjpeg($img); } elseif($type == 3) { $img_in = imagecreatefrompng($img); } elseif($type == 18) { $img_in = imagecreatefromwebp($img); } imageinterlace($img_in, true); $img_out = imagecreatetruecolor($largeur, $hauteur) or die ('Impossible de créer un flux d\'image GD'); imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in)); imagewebp($img_out, $miniature, 80); imagedestroy($img_out); } header('Content-Type: image/webp'); $data = file_get_contents($miniature); echo $data; clearstatcache(); } else {echo 'This is not an image';} ?>