Hudzilla.org - the homepage of Paul Hudson
Contents > Multimedia > Images Wish List | Report Bug | About Me ]

11.2.16     Introduction to special effects using simple algorithms

This 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:







<< 11.2.15 Special effects using imagefilter()   11.2.17 Special FX, Colour reduction: imagetruecolortopalette() >>
Table of Contents
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!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is ten plus three?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow