PHP: Resizing and Watermarking Images
1h 57mIntermediate2016-07-14
Authors

David Powers
Developing websites since 1994
Course details
Modern websites need to serve high-resolution images to avoid pixelation and blurring on high-pixel-density displays, but at a file size that loads quickly, even on mobile devices. This course shows how to use the GD functions in PHP to resize images and add an optional watermark to them. Author David Powers demonstrates how to calculate the correct scaling ratio by automatically measuring the dimensions and detecting the orientation of a JPEG image. He also explains how to add a watermark using text or, for a more polished result, an image blended with an alpha channel. All the techniques covered are completely nondestructive.
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.
Learning objectives
Scaling an image with imagescale()
Resizing an image with imagecopyresampled()
Adding watermarks
Correcting orientation
Batch processing images
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.
Learning objectives
Scaling an image with imagescale()
Resizing an image with imagecopyresampled()
Adding watermarks
Correcting orientation
Batch processing images
Skills covered
PHPProgramming LanguagesOpen SourceSoftware DevelopmentDeep Dive (X:Y)
Concepts
0. Introduction
- 01 - Welcome
- 02 - What you should know before watching this course
- 03 - Using the exercise files
1. Image Processing with GD
- 04 - Introducing the GD extension
- 05 - Scaling an image with imagescale()
- 06 - Getting an image's dimensions and MIME type
- 07 - Resizing an image with imagecopyresampled()
- 08 - Adding a text watermark
- 09 - Adding an image watermark
- 10 - Correcting an image's orientation
- 11 - Checking the MIME type and dimensions of a WebP image
- 12 - Converting to a different image format
2. Batch Processing Images
- 13 - Project overview
- 14 - Setting up the class definition
- 15 - Checking source images and orientation
- 16 - Setting output sizes and quality
- 17 - Adding an optional watermark
- 18 - Generating the output images
- 19 - Using the script
Conclusion
- 20 - What next