Index: sites/all/modules/brilliant_gallery/brilliant_gallery.module
===================================================================
--- sites/all/modules/brilliant_gallery/brilliant_gallery.module (revision 912)
+++ sites/all/modules/brilliant_gallery/brilliant_gallery.module (working copy)
@@ -189,6 +189,12 @@
'#maxlength' => 4,
'#description' => t("The maximum width of thumbnails in the table (height calculated automatically)."),
);
+ $form['brilliant_gallery_crop'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Crop images'),
+ '#default_value' => variable_get('brilliant_gallery_crop', TRUE),
+ '#description' => t("If selected, all images thumbnails have the same square size."),
+ );
$form['brilliant_gallery_bcgcolour'] = array(
'#type' => 'colorpicker',
'#title' => t('Table background colour'),
@@ -600,6 +606,7 @@
#$showcaption = $captionyesornot;
$showcaption = $captionyesnotext;
}
+ $imagecrop=variable_get('brilliant_gallery_crop', TRUE);
$padding = variable_get('brilliant_gallery_padding', 3);
$overbrowser = variable_get('brilliant_gallery_overbrowser', 'lightbox');
// Totally full resolution display would be impractical, so this is the maximum width of "full" resolution.
@@ -643,7 +650,7 @@
#$result .= $absolpath;
# Make an array with images in this folder, and their properties.
- $temp = load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort);
+ $temp = load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort, $imagecrop);
$retval_dimensions = $temp[0];
$imagemaxh = $temp[1];
$maxpoct = count($retval_dimensions);
@@ -721,6 +728,7 @@
$imgh = $retval_dimensions[$poct - 1]['imgh'];
$imgwbig = $retval_dimensions[$poct - 1]['imgwbig'];
$imghbig = $retval_dimensions[$poct - 1]['imghbig'];
+ $imgcrop = $retval_dimensions[$poct - 1]['imgcrop'];
#@$smallenough = $retval_dimensions[$poct - 1]['smallenough'];
#$style_li = "float: left; list-style: none; background: #000; width: 44px; height: 33px; padding: 4px; text-align: center; margin: 0; border: none;";
$style_li = "font-size:0; float: left; width: ". $imagewidth ."px; list-style: none; background: ". $bgcolour ."; height: ". $imagemaxh ."px; padding: ". $padding ."px; text-align: center; margin: 0px; border: none;";
@@ -785,7 +793,7 @@
#$result .= '
'; # width="' . $imgw . '"
#$result .= '
'; # width="' . $imgw . '"
# width="' . $imgw . '"
- $result .= '
';
+ $result .= '
';
#$result .= '';
$result .= '' . "\n";
}
Index: sites/all/modules/brilliant_gallery/functions.inc
===================================================================
--- sites/all/modules/brilliant_gallery/functions.inc (revision 912)
+++ sites/all/modules/brilliant_gallery/functions.inc (working copy)
@@ -36,7 +36,7 @@
}
-function load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort) {
+function load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort, $imagecrop) {
# Load Directory Into Array
$poct = -1;
$retval_dimensions = array();
@@ -51,6 +51,7 @@
$poct += 1;
#$retval[$poct] = $file;
$retval_dimensions[$poct]['file'] = $file;
+ $retval_dimensions[$poct]['imgcrop'] = $imagecrop;
# Is image horizontally or vertically oriented?
$temp = getimagesize($absolpath .'/'. $file);
@@ -72,8 +73,8 @@
}
else {
// This is a vertical image
- $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $imagewidth);
- $retval_dimensions[$poct]['imgh'] = round(($temp[0] / $temp[1]) * $imagewidth);
+ $retval_dimensions[$poct]['imgw'] = round(($temp[0] / $temp[1]) * $imagewidth);
+ $retval_dimensions[$poct]['imgh'] = $imagewidth;;
# if ($temp[0] > $fullresolutionmaxwidth) {
$retval_dimensions[$poct]['imgwbig'] = round(($temp[0] / $temp[1]) * ($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
$retval_dimensions[$poct]['imghbig'] = round(($temp[0] / $temp[1]) * $fullresolutionmaxwidth);
Index: sites/all/modules/brilliant_gallery/image.php
===================================================================
--- sites/all/modules/brilliant_gallery/image.php (revision 912)
+++ sites/all/modules/brilliant_gallery/image.php (working copy)
@@ -62,7 +62,7 @@
if ($lastchanged === false or (time() - $lastchanged > ($bgcachexpire))) {
#echo '. 1.... ';
# Cache file does not exist or is too old.
- $my_data = resizeimage($_GET['imgp'], $_GET['imgw'], $_GET['imgh']);
+ $my_data = resizeimage($_GET['imgp'], $_GET['imgw'], $_GET['imgh'], $_GET['imgcrop']);
# Now put $my_data to cache!
$fh = fopen($cachedfile, "w+");
fwrite($fh, $my_data);
@@ -101,7 +101,7 @@
else {
// Do your expensive calculations here, and populate $my_data
// with the correct stuff..
- $my_data = resizeimage($_GET['imgp'], $_GET['imgw'], $_GET['imgh']);
+ $my_data = resizeimage($_GET['imgp'], $_GET['imgw'], $_GET['imgh'], $_GET['imgcrop']);
#echo ' -2.... ' . $bgcachexpire . ' // ' . $my_data;
# For some reason I could not use: mysql_escape_string($my_data)
#cache_set($bgcacheid, 'cache', time() + $bgcachexpire, $my_data);
@@ -114,7 +114,7 @@
return $my_data;
}
-function resizeimage($imgp, $imgw, $imgh) {
+function resizeimage($imgp, $imgw, $imgh, $imgcrop) {
$imagepath = base64_decode($imgp);
#echo '.... ' . base64_decode( $imgp );
#flush();die(' stop!');
@@ -147,8 +147,23 @@
# Resize the image
$src_h = ImageSY($img);
$src_w = ImageSX($img);
- $dst_img = imagecreatetruecolor($imgw, $imgh);
- imagecopyresampled($dst_img, $img, 0, 0, 0, 0, $imgw, $imgh, $src_w, $src_h);
+ $dst_img = 0;
+ if ($imgcrop) {
+ if ($src_h>$src_w) {
+ // portrait
+ $dst_img = imagecreatetruecolor($imgh, $imgh);
+ imagecopyresampled($dst_img, $img, 0, 0, 0, ($src_h-$src_w)/2 , $imgh, $imgh, $src_w, $src_w);
+ }
+ else {
+ // landscape
+ $dst_img = imagecreatetruecolor($imgw, $imgw);
+ imagecopyresampled($dst_img, $img, 0, 0, ($src_w-$src_h)/2, 0 , $imgw, $imgw, $src_h, $src_h);
+ }
+ }
+ else {
+ $dst_img = imagecreatetruecolor($imgw, $imgh);
+ imagecopyresampled($dst_img, $img, 0, 0, 0, 0, $imgw, $imgh, $src_w, $src_h);
+ }
$img = $dst_img;
imageinterlace($img, 1);
imagecolortransparent($img);