11.2.16 Introduction to special effects using simple algorithmsThis is NOT the latest copy of this book; click here for the latest version.
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! For my examples, I have used the picture shown below:

|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|