First off, I'm really not sure where to post this, as it all depends on the solution! It might be CSS, it might be JavaScript, it might be PHP... that's half the problem. Okay, so I have a PHP-based forum with different skins/templates, one of which is a minimalist black and white design. Full color photos uploaded by users can grate with this color scheme, so what I'd like to do is have them automatically displayed in grayscale when viewed in this particular template, without editing the image file itself (so that it still displays in color in other templates). Even better would be to have a roll-over effect that turns the grayscaled image back into full color while the mouse is hovered over it, but that's an added luxury I can live without, as I'm really only planning to use this technique for thumbnails that will lead to the full color image in any template. What I need, then, is some kind of script or perhaps a CSS style to apply to these thumbnail images, but I've no idea where to begin. Can anyone please help?
You can do it with PHP + GD. It probably won't be much fun, but you should be able to get it to do exactly what you want. http://php.about.com/od/gdlibrary/ss/grayscale_gd.htm (read both pages) ---
Thanks Kerosene, that's what I need. But do you know how to display the output image? Just running the code "as is" displays a string of unreadable characters that make up the JPEG file, and changing the last line to something like this doesn't make much difference: echo '<img src="', imagejpeg($bwimage), '" />'; Code (markup): Is there a function that takes the image source code and turns it into a viewable picture?
Actually... this is a better example (and actually works). It creates a greyscale copy on your server, which may or may not be what you're after - depending on how many files you're dealing with. I just tried it and it works
I'm not expecting there to be many, but I'd like to avoid storing copies if possible. It must be possible to use the first method, I just don't know how to make it display the image instead of the source code. Perhaps I'll try saving the script in a separate file and calling it as an image, using parameters to specify the original file, like this: echo '<img src="grayscale_script.php?original=', $image, '" />; Code (markup): I'll give that a go later today when I have the chance, unless someone knows that it won't work.
EDIT: The method above works after all... I'd typed up a big description of the problems it was creating, but it was a stupid oversight and now thankfully resolved. Thanks again for your help Kerosene.