Introduction to special effects using simple algorithms

If there is one thing that has always struck me when working with newcomers to programming, it is that many of them think that certain things are out of their reach. For example, we have already looked at the code necessary to create pictures using PHP, but how would you make PHP blur that image so it looked out of focus without using a simple function call?

If you are already thinking "ouch, that is well out of my league - I wonder what is in the next chapter...", then stop! The title of this chapter is "special effects using simple algorithms ", which means I will be showing you how to create a variety of images using very simple techniques that I will explain step by step. Although the imagefilter() function is very helpful in providing some special effects functionality, if you can master the art of creating effects yourself using PHP it will give you a much deeper understanding of graphics and PHP.

The nine effects we will be looking at are, in order: colour reduce, interlace, screen, greyscale, duotone, noise, scatter, pixelate, and blur. Although writing these in PHP gives us more flexibility over the look of each effect, it does also mean they will be much slower than imagefilter() - you have been warned!


Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Special FX, Colour reduction >>

Previous chapter: Special effects using imagefilter()

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.