Photo Bar
The first step in getting the photo bar running is to get Gallery installed and running on your web site. The full instruction are on their site. This is a very good photo album program and was selected for integration into Contentor because of the rich set of features it contains. Note that Gallery requires a different set of features than Contentor to run. While it does not require the MySQL database, it does need a server that has the PHP 'safe mode' turned off. The graphics package Netpbm must be installed. Contact your web host administrator if in doubt about this capibility.
With the addition of a decent "built-in" graphics package within PHP and the constant upgrades to Gallery, I no longer recommend modifying Gallery. I am updating the File manager to do thumbnail generation and the PhotoBar program to adjust for mis-sized thumbnails.
I leave the instructions below (for now) for archival purposes.
Instructions for Gallery Version 1.3.1 .
Modifications to Gallery
Gallery can be modified to create all thumbnails with the same height (for horizonal photo bar) or the same width (for vertical photo bar).
Gallery Version 1.3.2 added support for the external graphics package ImageMagick in addition to NETPBM. Once the modification below is made, the thumbnail image size in the gallery properties would be appended with an 'h' or a 'w' to specify the desired height or width respectively. For example, to create a vertical photo bar of 120-pixel-wide images, set the thumbnail size to '120w'. Edit the file "util.php" to replace the function "resize_image" with the following code:
function resize_image($src, $dest, $target) {
global $gallery;
$fixedWidth = preg_match("~w$~i", $target); // for thumb 120w
$fixedHeight = preg_match("~h$~i", $target); // for thumb 120h
$target = 0 + $target; // force to integer
if (!strcmp($src,$dest)) {
$useTemp = true;
$out = "$dest.tmp";
} else {
$out = $dest;
}
// Check for images smaller then target size, don't blow them up.
$regs = getDimensions($src);
if ($regs[0] <= $target && $regs[1] <= $target) {
if ($useTemp == false) {
fs_copy($src, $dest);
}
return 1;
}
switch($gallery->app->graphics) {
case "NetPBM":
if ($fixedWidth) {
$err = exec_wrapper(toPnmCmd($src) . " | "
. NetPBM("pnmscale", " -width $target") . " | "
. fromPnmCmd($out));
} elseif ($fixedHeight) {
$err = exec_wrapper(toPnmCmd($src) . " | "
. NetPBM("pnmscale", " -height $target") . " | "
. fromPnmCmd($out));
} else {
$err = exec_wrapper(toPnmCmd($src) . " | " .
NetPBM("pnmscale", " -xysize $target $target") .
" | " . fromPnmCmd($out));
}
break;
case "ImageMagick":
$src = fs_import_filename($src);
$out = fs_import_filename($out);
if ($fixedWidth) {
$err = exec_wrapper(ImCmd("convert", "-quality ".
$gallery->app->jpegImageQuality .
" -size ". $target . "x" . $target . " $src".
" -geometry ". $target . "x +profile \"*\" $out"));
} elseif ($fixedHeight) {
$err = exec_wrapper(ImCmd("convert", "-quality ".
$gallery->app->jpegImageQuality .
" -size ". $target . "x" . $target . " $src".
" -geometry x" . $target .
" +profile \"*\" $out"));
} else {
$err = exec_wrapper(ImCmd("convert", "-quality ".
$gallery->app->jpegImageQuality .
" -size ". $target . "x" . $target . " $src".
" -geometry ". $target . "x" . $target .
" +profile \"*\" $out"));
}
break;
default:
if (isDebugging())
echo "You have no graphics package configured for use!";
return 0;
break;
}
if (fs_file_exists("$out") && fs_filesize("$out") > 0) {
if ($useTemp) {
fs_copy($out, $dest);
fs_unlink($out);
}
return 1;
} else {
return 0;
}
}
Automatic resizing upon upload
Gallery normally keeps the original upload file, no matter how large it may be. By adding the following code to the file "classes/Album.php", you can prevent the storage of a file larger than the "Auto-Resize" setting (in Album Properties).
Add the code after line # 628 in version 1.3.4 (which reads: "$item = new AlbumItem();") /* added to resize first */
$max_size = $gallery->album->fields["resize_size"];
list($w, $h) = getimagesize("$dir/$name.$tag");
if ($w > $max_size || $h > $max_size ) {
resize_image("$dir/$name.$tag", "$dir/$name.$tag", $max_size);
}