I was asked to develop a preview filter for Gallery, so users could preview images in b/w, sepiatone, etc and I think I've met with success.
It also allows frame-switching-not quite sure why, but it was requested.
If you have javascript enabled the page won't reload when just switching image filters (or shouldn't). Switching frames requires a reload.
I would love some feedback on how to improve this, and if anyone has a clue on how to make the filters a G2 module, please let me know! I'm trying on my own but it's a tough haul
You can see a sample in action at:
http://www.notgoddess.com/dev/gallery/IP_showcase/
(watch the bandwidth, tho, please
Requirements:
Gallery 1.5x (might work on earlier versions-with mods to inline imagewrap.inc)
PHP > 4.3.10 (might work on earlier versions, but unknown)
GD2 (maybe just GD)
I'm working on getting this to work with ImageMagick, but the results so far have been less that successfull.
Created images are cached in the album dir as [imagename].r.g.b.l.jpg for faster retrieval and less server-load. If you have plenty of server cycles but are limited on disk space you can edit the end of the filter script so it won't save (directions given if needed).
Files:
inline_imagewrap.inc: A replacement for the current version.
There are only 2 inserts, 1 near the top, and 1 at the end, so you shouldn't have problems putting it into your own if you've made mods.
imagePreview.php: The php file that builds the form, processes the requests.
Configuration for this add-on is at the top of this file.
imageFilter.php: The filtering script.
A summary of how to use this:
Make a backup of your inline_imagewrap.inc file
Download the zip file.
Make a backup of your inline_imagewrap.inc file if you didn't previously.
Put the three files in your html_wrap/ dir.
Edit the configuration at the top of imagePreview.php like so (a variation of this is in the file itself):
IP_filters:
Your array of available filters 'text' => 'filter'
text: Case-sensitive text to match from preview string below.
filter: 4 parts deliminated by '.'
1: Amount of red to add (0-255).
2: Amount of green to add (0-255).
3: Amount of blue to add (0-255).
4: Luminosity. (1-100). Well, not quite, but 100=brightest image.
There are several filters included in the source, some are:
'B/W' => '0.0.0.100',
'Black & White' => '0.0.0.80',
'Sepiatone' => '50.30.10.100',
'Sepiatone2' => '50.25.0.100',
'Denim' => '-30.-10.40.85',
'Red' => '50.0.0.100',
With the default settings, you'll see all of these on all images.
You can delete ones you don't want, or just comment them out.
There are 2 sepiatones and also 2 b/w filters because I'm still not quite sure which is closest to true. You can also rename these or tweak them.
IP_previews:
A comma deliminated list of previews to use if this image does not have the custom field 'Previews' set (see below). e.g. 'B/W, Sepiatone'
To only have previews on images with the custom field, set to false.
To include all possible filters (if no custom field), set to true;
Example: $IP_previews = 'Black & White, Sepiatone, Denim';
Would show those three filters on all images.
IP_frames:
false: No frame switching-option won't show.
true: Show all available (searches frames dir).
or an array of frames you want to offer. e.g. Array('shadows', 'notebook', 'dots');
Note, these must be valid frames or 'none'.
Image-specific previews:
I built in a way so you can set specific filters for specific images (e.g. an album of b/w photos...you wouldn't want 'b/w' as an option
You can add a custom field called 'Previews' and put a list there just like you did for IP_previews.
The filters must be in the IP_filters array, and exactly as there (case-sensitive, & not &, etc).
The script checks for that field and uses it instead of the default list when found.
This means you could have the default list set to false, and use the 'Previews' custom field to only show previews on specific images.
It is per-image, not per-album- I didn't see a way to do that.
Do note that the custom field will show. You can change what field is checked (change it it 'Previews Available' or whatever) but you have to edit the imagePreview.php script accordingly where it checks.
IP_formSubmit
One last thing-the variables are setup to pass by $_POST by default.
You can pass them by $_GET if you wish by changing this to 'get'.
Then go to your Gallery and give it a whirl!
I hope you enjoy this. Please report any problems you encounter.
I'll probably include it in Gallery Cart releases in the future.
Ng[/]