Join David Powers for an in-depth discussion in this video Checking the MIME type and dimensions of a WebP image, part of Resizing and Watermarking Images with PHP.
- [Voiceover] The get image size function…supports a wide range of image formats.…Unfortunately, at the time of recording this video…it doesn't work with the webp image format.…I'll show you how to work around this limitation,…but first a quick word about webp.…Although it's spelled web p, it's normally pronounced webp…and as this page explains, webp is a modern image format…that provides superior lossless and lossey compression…for images on the web,…and the images are considerably smaller in size…than png or jpeg.…
In the source folder for this course…is a file called pelican.webp.…The Windows file explorer and Mac finder can't preview it,…but if you've got Google Chrome installed…on your system as I have,…when you double click it it opens in chrome.…It's a high quality photo of a pelican on Stern's Warf,…not far from the linda.com headquarters.…Let's use get image size to inspect it.…I'm gonna switch to my editing program.…I've already created the script in webp_size.php…which you can find in the exercise files for this video.…
Chapter 2 pulls everything together, using a custom PHP class that can batch process multiple images, automatically detect the correct MIME type, generate custom sizes, and add an optional watermark.
- Scaling an image with imagescale()
- Resizing an image with imagecopyresampled()
- Adding watermarks
- Correcting orientation
- Batch processing images