From the course: PHP: Resizing and Watermarking Images

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Setting up the class definition

Setting up the class definition - PHP Tutorial

From the course: PHP: Resizing and Watermarking Images

Start my 1-month free trial

Setting up the class definition

- [Voiceover] Creating a custom class to resize images involves a lot of code. I've already started the class definition in ResizeImages.php which you can find in the chapter two 02_02 folder of the exercise files. It begins on line two by declaring a namespace to avoid potential clashes with classes from other sources. I've chosen Foundationphp as the namespace because that's the domain name of my website. Then there's a list of protected properties. I'll explain what most of them are for when they're used. Here on line eight, mimeTypes is an array of image formats supported on the web. The next two lines, webpSupported and useImageScale are Boolean properties that assume the server supports working with webp images and the image scale function. The class constructor method detects the version of php running on the server and resets these to false if they're not supported. jpegQuality is set to 75 and pngCompression is set to zero. These are the same as the php defaults, but we need…

Contents