aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Image/Gd
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Library/Image/Gd')
-rw-r--r--h-source/Library/Image/Gd/Captcha.php5
-rw-r--r--h-source/Library/Image/Gd/Thumbnail.php24
2 files changed, 23 insertions, 6 deletions
diff --git a/h-source/Library/Image/Gd/Captcha.php b/h-source/Library/Image/Gd/Captcha.php
index b414b13..8a128eb 100644
--- a/h-source/Library/Image/Gd/Captcha.php
+++ b/h-source/Library/Image/Gd/Captcha.php
@@ -39,7 +39,8 @@ class Image_Gd_Captcha
'fontPath' => $here.'/External/Fonts/FreeFont/FreeMono.ttf',
'undulation' => true,
'align' => false,
- 'charHeight' => 28
+ 'charHeight' => 28,
+ 'sessionKey' => 'captchaString',
);
//set the $this->scaffold->params array
@@ -91,7 +92,7 @@ class Image_Gd_Captcha
imagefilledellipse($img, mt_rand(0,$this->params['boxWidth']), mt_rand(0,$this->params['boxHeight']), 1, 1, $noiseColor);
}
- $_SESSION['captchaString'] = $this->string;
+ $_SESSION[$this->params['sessionKey']] = $this->string;
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
diff --git a/h-source/Library/Image/Gd/Thumbnail.php b/h-source/Library/Image/Gd/Thumbnail.php
index 742aa17..9bf2500 100644
--- a/h-source/Library/Image/Gd/Thumbnail.php
+++ b/h-source/Library/Image/Gd/Thumbnail.php
@@ -41,7 +41,9 @@ class Image_Gd_Thumbnail
'defaultImage' => null,
'cropImage' => 'no',
'horizAlign' => 'left',
- 'vertAlign' => 'top'
+ 'vertAlign' => 'top',
+ 'resample' => 'yes',
+ 'function' => 'none',
);
//set the $this->scaffold->params array
@@ -144,10 +146,24 @@ class Image_Gd_Thumbnail
//temp image
$tmpImg = imagecreatetruecolor($newWidth, $newHeight);
- //copy and resize
- imagecopyresized($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height);
+ if ($this->params['resample'] === 'yes')
+ {
+ //copy and resample
+ imagecopyresampled($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height);
+ }
+ else
+ {
+ //copy and resize
+ imagecopyresized($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height);
+ }
imagedestroy($img);
$img = $tmpImg;
+
+ if (!function_exists($this->params['function'])) {
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$this->params['function']. '</b> does not exist');
+ }
+
+ $img = call_user_func($this->params['function'],$img);
}
}
@@ -159,7 +175,7 @@ class Image_Gd_Thumbnail
//print the image
header("Content-type: image/jpeg");
- imagejpeg($img);
+ imagejpeg($img,null,90);
}