Understand WebP Image Mime Type and PHP Output it in Browser Directly – PHP Tutorial

By | August 3, 2019

WebP image is a popular image format using in web development. In this tutorial, we will discuss what its mime type is and how to output is to our browser using php directly.

webp image tutorials and examples

Mime Type of WebP

It is:

image/webp

To output it to browsers using php, you should do like:

Send a mime type header

<?php
header("Content-Type: image/webp");
?>

Read a webp image and output it

<?php
echo file_get_contents($file);
?>

Then you will find this webp image appear in our browser.

Category: PHP

Leave a Reply

Your email address will not be published. Required fields are marked *