![]() | | ![]() |
This PHP script, Easy Reflections v3 by Richard Davey (corephp.co.uk), produces a reflection of an image. This image effect is also known as the "wet-floor" effect. This script offloads the burden of generating the reflected image onto the server computer rather than using the visitor’s computer and javascript, but the trade off is that there is an extra image to download. However, if the visitor has javascript disabled, this script will still produce a visible image. To use this script, versions PHP 4.3.2+ and the GD library 2.0.1+ are required.
Version 3.0 (check the author’s site for more recent versions)
After extracting the reflect_v3.php file, upload it to your site. No code alterations are needed for the script to work with SiteSpinner. To use the script, place an image on your work page, then open a code object and enter:

where picture-filename is the filename of the image to be reflected. The default size of the reflect image is 50% of the original, so alter the height of the code object to the correct size.
Because the image filename is being specified in a code object, you will need to append the path name to the image. Normally this is ./image but may be different if you upload images yourself or change the default location. If the image to be reflected needs to be resized on your work page, do it using an external program. When you use SiteSpinner to re-size an image, SiteSpinner will generate a unique filename for the scaled image and you will not know what that new name is.
When you position the code object for the reflection under the original image, make sure the edges touch or there will be a gap between the two. Once you have the two objects linked together, you should make a permanent group of them. This will allow you to move them together without risking them becoming separated.
There are six parameters that can be passed to the script, described below. Only the img parameter is required; the remainder are optional. (Parameters are passed to the PHP script as a query string.)
| img | The first parameter, which is required, specifies the path and filename of the image to reflect. The image file must exist on your web site; URLs are not allowed. Version 3 can accept GIF, JPG or PNG image types. Examples:
|
| height | This sets the height of the reflection image. The value can be set in either pixels or a percentage value. If no height parameter is given, a default of 50% is used. If you do not know the height of the source image then it is better to use a percentage value. If the source image is always of a fixed size, then you can set a pixel value which allows your HTML img tag to validate, because you can set a width and height value to it. Examples:
|
| fade_start | This parameter sets the starting alpha (transparency) value. There are 127 levels of alpha, beginning at 127 (no fade at all) to 1 (completely opaque). You can also specify this value as a percentage (50%, 80%, etc). To get the best reflection effect, start the alpha level off at 80 (the default), and play with it to get the effect you want. One thing to bear in mind: the higher this value, the more height you’ll need to allow the reflection to show. Examples:
|
| fade_end | The fade_end parameter sets the alpha value at which the fade will end. A setting of 1 (the default) will fade completely to the background color. A setting of 63 (or 50%) would fade to half brightness. Examples:
|
| tint | You can change the color tint of the reflection by passing a color value with this parameter. The default is no tint. For example, increase the blue channel for a more ‘watery’ effect. The value should be given as a standard HTML color hex code (3 or 6 characters). Values over 9 will "over-tint" the image, causing a saturation effect. The hash (#) at the start is optional and on some PHP configurations should be left out totally. Examples:
|
| cache | Turn cache support on or off by using this parameter. By default the cache is disabled. When the script first executes, the reflection image is generated and saved in the image’s source directory. If the page is refreshed and the cache option is disabled, the script will re-generate the reflection image. If the cache option is turned on, then the previously generated image will be sent to the browser instead of recreating it. Write permission must be set on the directory for this to work. Examples:
|


Contact the LowTechGeezer
VM User's Forum
Bruceee's Sandpit
Webmaster's Corner
Other Useful Sites
Ooops! I somehow made the reflecions on your page disappear! Man, am I wrong! Help!
Linda
This isn’t working for me. I use SSPro with a computer that runs Vista. Tell me what part of this I’m doing wrong:
1. I unzipped the file and went to the ‘Embed A File or Media’ w/ ‘Publish File’ format and the file path led to the unzipped ‘PHP reflect’ file and just put it on the page.
2. I emport a jpeg picture, already pre-sized.
3. I opened a text editor, code edit mode and placed your code in it with ‘efc6′ (which is the name of the jpeg picture I imported) in the place of ‘picture_filename’ in your code and I placed this under my jpeg picture, exactly touching the bottom and made them both into a group. Then I put them ‘To the front’.
Uuggghhh! I tired of trying this and coming up zip and I want this to work! Help!
Linda
(I use SiteSpinner Pro and my computer runs Vista- just in case it matters.) After downloading (saving) the file, how exactly do I extract the file? Does uploading it to my site mean just publishing my web site?