|
From: <be...@us...> - 2013-09-14 04:38:09
|
Revision: 12034
http://sourceforge.net/p/xoops/svn/12034
Author: beckmi
Date: 2013-09-14 04:38:02 +0000 (Sat, 14 Sep 2013)
Log Message:
-----------
removing php_closing_tag in few more files
Modified Paths:
--------------
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopscode.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsemotions.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsimagemanager.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsmlcontent.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsquote.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/language/english.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/modules/system/class/thumbs/phpthumb.filters.php
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopscode.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopscode.php 2013-09-14 03:16:44 UTC (rev 12033)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopscode.php 2013-09-14 04:38:02 UTC (rev 12034)
@@ -16,4 +16,3 @@
// Add your code here to check acces by groups
return true;
-?>
\ No newline at end of file
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsemotions.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsemotions.php 2013-09-14 03:16:44 UTC (rev 12033)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsemotions.php 2013-09-14 04:38:02 UTC (rev 12034)
@@ -17,4 +17,3 @@
// Add your code here to check acces by groups
return true;
-?>
\ No newline at end of file
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsimagemanager.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsimagemanager.php 2013-09-14 03:16:44 UTC (rev 12033)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsimagemanager.php 2013-09-14 04:38:02 UTC (rev 12034)
@@ -20,4 +20,3 @@
return false;
}
return true;
-?>
\ No newline at end of file
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsmlcontent.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsmlcontent.php 2013-09-14 03:16:44 UTC (rev 12033)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsmlcontent.php 2013-09-14 04:38:02 UTC (rev 12034)
@@ -24,4 +24,3 @@
}
return false;
-?>
\ No newline at end of file
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsquote.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsquote.php 2013-09-14 03:16:44 UTC (rev 12033)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/include/xoopsquote.php 2013-09-14 04:38:02 UTC (rev 12034)
@@ -16,4 +16,3 @@
// Add your code here to check acces by groups
return true;
-?>
\ No newline at end of file
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/language/english.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/language/english.php 2013-09-14 03:16:44 UTC (rev 12033)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/xoopseditor/tinymce/language/english.php 2013-09-14 04:38:02 UTC (rev 12034)
@@ -20,4 +20,3 @@
define('_XOOPS_EDITOR_TINYMCE_LANGUAGE',"en");
// FONT LIST, FORMAT: "Name=value1,value2;Name=value"
define('_XOOPS_EDITOR_TINYMCE_FONTS',"Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings");
-?>
\ No newline at end of file
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/modules/system/class/thumbs/phpthumb.filters.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/modules/system/class/thumbs/phpthumb.filters.php 2013-09-14 03:16:44 UTC (rev 12033)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/modules/system/class/thumbs/phpthumb.filters.php 2013-09-14 04:38:02 UTC (rev 12034)
@@ -10,61 +10,62 @@
class phpthumb_filters {
- var $phpThumbObject = null;
+ var $phpThumbObject = null;
- function phpthumb_filters() {
- return true;
- }
+ function phpthumb_filters() {
+ return true;
+ }
- function ApplyMask(&$gdimg_mask, &$gdimg_image) {
- if (phpthumb_functions::gd_version() < 2) {
- $this->DebugMessage('Skipping ApplyMask() because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__);
- return false;
- }
- if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=')) {
+ function ApplyMask(&$gdimg_mask, &$gdimg_image) {
+ if (phpthumb_functions::gd_version() < 2) {
+ $this->DebugMessage('Skipping ApplyMask() because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__);
- $this->DebugMessage('Using alpha ApplyMask() technique', __FILE__, __LINE__);
- if ($gdimg_mask_resized = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_image), ImageSY($gdimg_image))) {
+ return false;
+ }
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=')) {
- ImageCopyResampled($gdimg_mask_resized, $gdimg_mask, 0, 0, 0, 0, ImageSX($gdimg_image), ImageSY($gdimg_image), ImageSX($gdimg_mask), ImageSY($gdimg_mask));
- if ($gdimg_mask_blendtemp = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_image), ImageSY($gdimg_image))) {
+ $this->DebugMessage('Using alpha ApplyMask() technique', __FILE__, __LINE__);
+ if ($gdimg_mask_resized = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_image), ImageSY($gdimg_image))) {
- $color_background = ImageColorAllocate($gdimg_mask_blendtemp, 0, 0, 0);
- ImageFilledRectangle($gdimg_mask_blendtemp, 0, 0, ImageSX($gdimg_mask_blendtemp), ImageSY($gdimg_mask_blendtemp), $color_background);
- ImageAlphaBlending($gdimg_mask_blendtemp, false);
- ImageSaveAlpha($gdimg_mask_blendtemp, true);
- for ($x = 0; $x < ImageSX($gdimg_image); $x++) {
- for ($y = 0; $y < ImageSY($gdimg_image); $y++) {
- //$RealPixel = phpthumb_functions::GetPixelColor($gdimg_mask_blendtemp, $x, $y);
- $RealPixel = phpthumb_functions::GetPixelColor($gdimg_image, $x, $y);
- $MaskPixel = phpthumb_functions::GrayscalePixel(phpthumb_functions::GetPixelColor($gdimg_mask_resized, $x, $y));
- $MaskAlpha = 127 - (floor($MaskPixel['red'] / 2) * (1 - ($RealPixel['alpha'] / 127)));
- $newcolor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_mask_blendtemp, $RealPixel['red'], $RealPixel['green'], $RealPixel['blue'], $MaskAlpha);
- ImageSetPixel($gdimg_mask_blendtemp, $x, $y, $newcolor);
- }
- }
- ImageAlphaBlending($gdimg_image, false);
- ImageSaveAlpha($gdimg_image, true);
- ImageCopy($gdimg_image, $gdimg_mask_blendtemp, 0, 0, 0, 0, ImageSX($gdimg_mask_blendtemp), ImageSY($gdimg_mask_blendtemp));
- ImageDestroy($gdimg_mask_blendtemp);
+ ImageCopyResampled($gdimg_mask_resized, $gdimg_mask, 0, 0, 0, 0, ImageSX($gdimg_image), ImageSY($gdimg_image), ImageSX($gdimg_mask), ImageSY($gdimg_mask));
+ if ($gdimg_mask_blendtemp = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_image), ImageSY($gdimg_image))) {
- } else {
- $this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__);
- }
- ImageDestroy($gdimg_mask_resized);
+ $color_background = ImageColorAllocate($gdimg_mask_blendtemp, 0, 0, 0);
+ ImageFilledRectangle($gdimg_mask_blendtemp, 0, 0, ImageSX($gdimg_mask_blendtemp), ImageSY($gdimg_mask_blendtemp), $color_background);
+ ImageAlphaBlending($gdimg_mask_blendtemp, false);
+ ImageSaveAlpha($gdimg_mask_blendtemp, true);
+ for ($x = 0; $x < ImageSX($gdimg_image); $x++) {
+ for ($y = 0; $y < ImageSY($gdimg_image); $y++) {
+ //$RealPixel = phpthumb_functions::GetPixelColor($gdimg_mask_blendtemp, $x, $y);
+ $RealPixel = phpthumb_functions::GetPixelColor($gdimg_image, $x, $y);
+ $MaskPixel = phpthumb_functions::GrayscalePixel(phpthumb_functions::GetPixelColor($gdimg_mask_resized, $x, $y));
+ $MaskAlpha = 127 - (floor($MaskPixel['red'] / 2) * (1 - ($RealPixel['alpha'] / 127)));
+ $newcolor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_mask_blendtemp, $RealPixel['red'], $RealPixel['green'], $RealPixel['blue'], $MaskAlpha);
+ ImageSetPixel($gdimg_mask_blendtemp, $x, $y, $newcolor);
+ }
+ }
+ ImageAlphaBlending($gdimg_image, false);
+ ImageSaveAlpha($gdimg_image, true);
+ ImageCopy($gdimg_image, $gdimg_mask_blendtemp, 0, 0, 0, 0, ImageSX($gdimg_mask_blendtemp), ImageSY($gdimg_mask_blendtemp));
+ ImageDestroy($gdimg_mask_blendtemp);
- } else {
- $this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__);
- }
+ } else {
+ $this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__);
+ }
+ ImageDestroy($gdimg_mask_resized);
- } else {
- // alpha merging requires PHP v4.3.2+
- $this->DebugMessage('Skipping ApplyMask() technique because PHP is v"'.phpversion().'"', __FILE__, __LINE__);
- }
- return true;
- }
+ } else {
+ $this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__);
+ }
+ } else {
+ // alpha merging requires PHP v4.3.2+
+ $this->DebugMessage('Skipping ApplyMask() technique because PHP is v"'.phpversion().'"', __FILE__, __LINE__);
+ }
+ return true;
+ }
+
function Bevel(&$gdimg, $width, $hexcolor1, $hexcolor2) {
$width = ($width ? $width : 5);
$hexcolor1 = ($hexcolor1 ? $hexcolor1 : 'FFFFFF');
@@ -81,1464 +82,1501 @@
ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i - 1, ImageSX($gdimg) - $i, $i + 1, $color2); // right
ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i , $i, ImageSY($gdimg) - $i , $color2); // bottom
}
+
return true;
}
+ function Blur(&$gdimg, $radius=0.5) {
+ // Taken from Torstein H\xF8nsi's phpUnsharpMask (see phpthumb.unsharp.php)
- function Blur(&$gdimg, $radius=0.5) {
- // Taken from Torstein H\xF8nsi's phpUnsharpMask (see phpthumb.unsharp.php)
+ $radius = round(max(0, min($radius, 50)) * 2);
+ if (!$radius) {
+ return false;
+ }
- $radius = round(max(0, min($radius, 50)) * 2);
- if (!$radius) {
- return false;
- }
+ $w = ImageSX($gdimg);
+ $h = ImageSY($gdimg);
+ if ($imgBlur = ImageCreateTrueColor($w, $h)) {
+ // Gaussian blur matrix:
+ // 1 2 1
+ // 2 4 2
+ // 1 2 1
- $w = ImageSX($gdimg);
- $h = ImageSY($gdimg);
- if ($imgBlur = ImageCreateTrueColor($w, $h)) {
- // Gaussian blur matrix:
- // 1 2 1
- // 2 4 2
- // 1 2 1
+ // Move copies of the image around one pixel at the time and merge them with weight
+ // according to the matrix. The same matrix is simply repeated for higher radii.
+ for ($i = 0; $i < $radius; $i++) {
+ ImageCopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1); // up left
+ ImageCopyMerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.00000); // down right
+ ImageCopyMerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left
+ ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25.00000); // up right
+ ImageCopyMerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left
+ ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.00000); // right
+ ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20.00000); // up
+ ImageCopyMerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667); // down
+ ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.000000); // center
+ ImageCopy ($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h);
+ }
- // Move copies of the image around one pixel at the time and merge them with weight
- // according to the matrix. The same matrix is simply repeated for higher radii.
- for ($i = 0; $i < $radius; $i++) {
- ImageCopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1); // up left
- ImageCopyMerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.00000); // down right
- ImageCopyMerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left
- ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25.00000); // up right
- ImageCopyMerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left
- ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.00000); // right
- ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20.00000); // up
- ImageCopyMerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667); // down
- ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.000000); // center
- ImageCopy ($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h);
- }
- return true;
- }
- return false;
- }
+ return true;
+ }
+ return false;
+ }
- function BlurGaussian(&$gdimg) {
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- if (ImageFilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
- $this->DebugMessage('FAILED: phpthumb_filters::BlurGaussian($gdimg) [using phpthumb_filters::Blur() instead]', __FILE__, __LINE__);
- return phpthumb_filters::Blur($gdimg, 0.5);
- }
+ function BlurGaussian(&$gdimg) {
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ if (ImageFilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
+ $this->DebugMessage('FAILED: phpthumb_filters::BlurGaussian($gdimg) [using phpthumb_filters::Blur() instead]', __FILE__, __LINE__);
- function BlurSelective(&$gdimg) {
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- if (ImageFilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
- // currently not implemented "the hard way"
- $this->DebugMessage('FAILED: phpthumb_filters::BlurSelective($gdimg) [function not implemented]', __FILE__, __LINE__);
- return false;
- }
+ return phpthumb_filters::Blur($gdimg, 0.5);
+ }
- function Brightness(&$gdimg, $amount=0) {
- if ($amount == 0) {
- return true;
- }
- $amount = max(-255, min(255, $amount));
+ function BlurSelective(&$gdimg) {
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ if (ImageFilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
+ // currently not implemented "the hard way"
+ $this->DebugMessage('FAILED: phpthumb_filters::BlurSelective($gdimg) [function not implemented]', __FILE__, __LINE__);
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- if (ImageFilter($gdimg, IMG_FILTER_BRIGHTNESS, $amount)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_BRIGHTNESS, '.$amount.')', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
+ return false;
+ }
- $scaling = (255 - abs($amount)) / 255;
- $baseamount = (($amount > 0) ? $amount : 0);
- for ($x = 0; $x < ImageSX($gdimg); $x++) {
- for ($y = 0; $y < ImageSY($gdimg); $y++) {
- $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
- foreach ($OriginalPixel as $key => $value) {
- $NewPixel[$key] = round($baseamount + ($OriginalPixel[$key] * $scaling));
- }
- $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']);
- ImageSetPixel($gdimg, $x, $y, $newColor);
- }
- }
- return true;
- }
+ function Brightness(&$gdimg, $amount=0) {
+ if ($amount == 0) {
+ return true;
+ }
+ $amount = max(-255, min(255, $amount));
- function Contrast(&$gdimg, $amount=0) {
- if ($amount == 0) {
- return true;
- }
- $amount = max(-255, min(255, $amount));
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ if (ImageFilter($gdimg, IMG_FILTER_BRIGHTNESS, $amount)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_BRIGHTNESS, '.$amount.')', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- // ImageFilter(IMG_FILTER_CONTRAST) has range +100 to -100 (positive numbers make it darker!)
- $amount = ($amount / 255) * -100;
- if (ImageFilter($gdimg, IMG_FILTER_CONTRAST, $amount)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_CONTRAST, '.$amount.')', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
+ $scaling = (255 - abs($amount)) / 255;
+ $baseamount = (($amount > 0) ? $amount : 0);
+ for ($x = 0; $x < ImageSX($gdimg); $x++) {
+ for ($y = 0; $y < ImageSY($gdimg); $y++) {
+ $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
+ foreach ($OriginalPixel as $key => $value) {
+ $NewPixel[$key] = round($baseamount + ($OriginalPixel[$key] * $scaling));
+ }
+ $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']);
+ ImageSetPixel($gdimg, $x, $y, $newColor);
+ }
+ }
- if ($amount > 0) {
- $scaling = 1 + ($amount / 255);
- } else {
- $scaling = (255 - abs($amount)) / 255;
- }
- for ($x = 0; $x < ImageSX($gdimg); $x++) {
- for ($y = 0; $y < ImageSY($gdimg); $y++) {
- $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
- foreach ($OriginalPixel as $key => $value) {
- $NewPixel[$key] = min(255, max(0, round($OriginalPixel[$key] * $scaling)));
- }
- $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']);
- ImageSetPixel($gdimg, $x, $y, $newColor);
- }
- }
- }
+ return true;
+ }
- function Colorize(&$gdimg, $amount, $targetColor) {
- $amount = (is_numeric($amount) ? $amount : 25);
- $amountPct = $amount / 100;
- $targetColor = (phpthumb_functions::IsHexColor($targetColor) ? $targetColor : 'gray');
+ function Contrast(&$gdimg, $amount=0) {
+ if ($amount == 0) {
+ return true;
+ }
+ $amount = max(-255, min(255, $amount));
- if ($amount == 0) {
- return true;
- }
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ // ImageFilter(IMG_FILTER_CONTRAST) has range +100 to -100 (positive numbers make it darker!)
+ $amount = ($amount / 255) * -100;
+ if (ImageFilter($gdimg, IMG_FILTER_CONTRAST, $amount)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_CONTRAST, '.$amount.')', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- if ($targetColor == 'gray') {
- $targetColor = '808080';
- }
- $r = round($amountPct * hexdec(substr($targetColor, 0, 2)));
- $g = round($amountPct * hexdec(substr($targetColor, 2, 2)));
- $b = round($amountPct * hexdec(substr($targetColor, 4, 2)));
- if (ImageFilter($gdimg, IMG_FILTER_COLORIZE, $r, $g, $b)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_COLORIZE)', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
+ if ($amount > 0) {
+ $scaling = 1 + ($amount / 255);
+ } else {
+ $scaling = (255 - abs($amount)) / 255;
+ }
+ for ($x = 0; $x < ImageSX($gdimg); $x++) {
+ for ($y = 0; $y < ImageSY($gdimg); $y++) {
+ $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
+ foreach ($OriginalPixel as $key => $value) {
+ $NewPixel[$key] = min(255, max(0, round($OriginalPixel[$key] * $scaling)));
+ }
+ $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']);
+ ImageSetPixel($gdimg, $x, $y, $newColor);
+ }
+ }
+ }
- // overridden below for grayscale
- if ($targetColor != 'gray') {
- $TargetPixel['red'] = hexdec(substr($targetColor, 0, 2));
- $TargetPixel['green'] = hexdec(substr($targetColor, 2, 2));
- $TargetPixel['blue'] = hexdec(substr($targetColor, 4, 2));
- }
- for ($x = 0; $x < ImageSX($gdimg); $x++) {
- for ($y = 0; $y < ImageSY($gdimg); $y++) {
- $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
- if ($targetColor == 'gray') {
- $TargetPixel = phpthumb_functions::GrayscalePixel($OriginalPixel);
- }
- foreach ($TargetPixel as $key => $value) {
- $NewPixel[$key] = round(max(0, min(255, ($OriginalPixel[$key] * ((100 - $amount) / 100)) + ($TargetPixel[$key] * $amountPct))));
- }
- //$newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue'], $OriginalPixel['alpha']);
- $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']);
- ImageSetPixel($gdimg, $x, $y, $newColor);
- }
- }
- return true;
- }
+ function Colorize(&$gdimg, $amount, $targetColor) {
+ $amount = (is_numeric($amount) ? $amount : 25);
+ $amountPct = $amount / 100;
+ $targetColor = (phpthumb_functions::IsHexColor($targetColor) ? $targetColor : 'gray');
+ if ($amount == 0) {
+ return true;
+ }
- function Crop(&$gdimg, $left=0, $right=0, $top=0, $bottom=0) {
- if (!$left && !$right && !$top && !$bottom) {
- return true;
- }
- $oldW = ImageSX($gdimg);
- $oldH = ImageSY($gdimg);
- if (($left > 0) && ($left < 1)) { $left = round($left * $oldW); }
- if (($right > 0) && ($right < 1)) { $right = round($right * $oldW); }
- if (($top > 0) && ($top < 1)) { $top = round($top * $oldH); }
- if (($bottom > 0) && ($bottom < 1)) { $bottom = round($bottom * $oldH); }
- $right = min($oldW - $left - 1, $right);
- $bottom = min($oldH - $top - 1, $bottom);
- $newW = $oldW - $left - $right;
- $newH = $oldH - $top - $bottom;
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ if ($targetColor == 'gray') {
+ $targetColor = '808080';
+ }
+ $r = round($amountPct * hexdec(substr($targetColor, 0, 2)));
+ $g = round($amountPct * hexdec(substr($targetColor, 2, 2)));
+ $b = round($amountPct * hexdec(substr($targetColor, 4, 2)));
+ if (ImageFilter($gdimg, IMG_FILTER_COLORIZE, $r, $g, $b)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_COLORIZE)', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
- if ($imgCropped = ImageCreateTrueColor($newW, $newH)) {
- ImageCopy($imgCropped, $gdimg, 0, 0, $left, $top, $newW, $newH);
- if ($gdimg = ImageCreateTrueColor($newW, $newH)) {
- ImageCopy($gdimg, $imgCropped, 0, 0, 0, 0, $newW, $newH);
- ImageDestroy($imgCropped);
- return true;
- }
- ImageDestroy($imgCropped);
- }
- return false;
- }
+ // overridden below for grayscale
+ if ($targetColor != 'gray') {
+ $TargetPixel['red'] = hexdec(substr($targetColor, 0, 2));
+ $TargetPixel['green'] = hexdec(substr($targetColor, 2, 2));
+ $TargetPixel['blue'] = hexdec(substr($targetColor, 4, 2));
+ }
+ for ($x = 0; $x < ImageSX($gdimg); $x++) {
+ for ($y = 0; $y < ImageSY($gdimg); $y++) {
+ $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
+ if ($targetColor == 'gray') {
+ $TargetPixel = phpthumb_functions::GrayscalePixel($OriginalPixel);
+ }
+ foreach ($TargetPixel as $key => $value) {
+ $NewPixel[$key] = round(max(0, min(255, ($OriginalPixel[$key] * ((100 - $amount) / 100)) + ($TargetPixel[$key] * $amountPct))));
+ }
+ //$newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue'], $OriginalPixel['alpha']);
+ $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']);
+ ImageSetPixel($gdimg, $x, $y, $newColor);
+ }
+ }
- function Desaturate(&$gdimg, $amount, $color='') {
- if ($amount == 0) {
- return true;
- }
- return phpthumb_filters::Colorize($gdimg, $amount, (phpthumb_functions::IsHexColor($color) ? $color : 'gray'));
- }
+ return true;
+ }
- function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha) {
- if (phpthumb_functions::gd_version() < 2) {
- return false;
- }
- $distance = ($distance ? $distance : 10);
- $width = ($width ? $width : 10);
- $hexcolor = ($hexcolor ? $hexcolor : '000000');
- $angle = ($angle ? $angle : 225) % 360;
- $alpha = max(0, min(100, ($alpha ? $alpha : 100)));
+ function Crop(&$gdimg, $left=0, $right=0, $top=0, $bottom=0) {
+ if (!$left && !$right && !$top && !$bottom) {
+ return true;
+ }
+ $oldW = ImageSX($gdimg);
+ $oldH = ImageSY($gdimg);
+ if (($left > 0) && ($left < 1)) { $left = round($left * $oldW); }
+ if (($right > 0) && ($right < 1)) { $right = round($right * $oldW); }
+ if (($top > 0) && ($top < 1)) { $top = round($top * $oldH); }
+ if (($bottom > 0) && ($bottom < 1)) { $bottom = round($bottom * $oldH); }
+ $right = min($oldW - $left - 1, $right);
+ $bottom = min($oldH - $top - 1, $bottom);
+ $newW = $oldW - $left - $right;
+ $newH = $oldH - $top - $bottom;
- if ($alpha <= 0) {
- // invisible shadow, nothing to do
- return true;
- }
- if ($distance <= 0) {
- // shadow completely obscured by source image, nothing to do
- return true;
- }
+ if ($imgCropped = ImageCreateTrueColor($newW, $newH)) {
+ ImageCopy($imgCropped, $gdimg, 0, 0, $left, $top, $newW, $newH);
+ if ($gdimg = ImageCreateTrueColor($newW, $newH)) {
+ ImageCopy($gdimg, $imgCropped, 0, 0, 0, 0, $newW, $newH);
+ ImageDestroy($imgCropped);
- $width_shadow = cos(deg2rad($angle)) * ($distance + $width);
- $height_shadow = sin(deg2rad($angle)) * ($distance + $width);
+ return true;
+ }
+ ImageDestroy($imgCropped);
+ }
- $scaling = min(ImageSX($gdimg) / (ImageSX($gdimg) + abs($width_shadow)), ImageSY($gdimg) / (ImageSY($gdimg) + abs($height_shadow)));
+ return false;
+ }
- for ($i = 0; $i < $width; $i++) {
- $WidthAlpha[$i] = (abs(($width / 2) - $i) / $width);
- $Offset['x'] = cos(deg2rad($angle)) * ($distance + $i);
- $Offset['y'] = sin(deg2rad($angle)) * ($distance + $i);
- }
- $tempImageWidth = ImageSX($gdimg) + abs($Offset['x']);
- $tempImageHeight = ImageSY($gdimg) + abs($Offset['y']);
+ function Desaturate(&$gdimg, $amount, $color='') {
+ if ($amount == 0) {
+ return true;
+ }
- if ($gdimg_dropshadow_temp = phpthumb_functions::ImageCreateFunction($tempImageWidth, $tempImageHeight)) {
+ return phpthumb_filters::Colorize($gdimg, $amount, (phpthumb_functions::IsHexColor($color) ? $color : 'gray'));
+ }
- ImageAlphaBlending($gdimg_dropshadow_temp, false);
- ImageSaveAlpha($gdimg_dropshadow_temp, true);
- $transparent1 = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_dropshadow_temp, 0, 0, 0, 127);
- ImageFill($gdimg_dropshadow_temp, 0, 0, $transparent1);
- for ($x = 0; $x < ImageSX($gdimg); $x++) {
- for ($y = 0; $y < ImageSY($gdimg); $y++) {
- $PixelMap[$x][$y] = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
- }
- }
- for ($x = 0; $x < $tempImageWidth; $x++) {
- for ($y = 0; $y < $tempImageHeight; $y++) {
- //for ($i = 0; $i < $width; $i++) {
- for ($i = 0; $i < 1; $i++) {
- if (!isset($PixelMap[$x][$y]['alpha']) || ($PixelMap[$x][$y]['alpha'] > 0)) {
- if (isset($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']) && ($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha'] < 127)) {
- $thisColor = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor, false, $PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']);
- ImageSetPixel($gdimg_dropshadow_temp, $x, $y, $thisColor);
- }
- }
- }
- }
- }
+ function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha) {
+ if (phpthumb_functions::gd_version() < 2) {
+ return false;
+ }
+ $distance = ($distance ? $distance : 10);
+ $width = ($width ? $width : 10);
+ $hexcolor = ($hexcolor ? $hexcolor : '000000');
+ $angle = ($angle ? $angle : 225) % 360;
+ $alpha = max(0, min(100, ($alpha ? $alpha : 100)));
- ImageAlphaBlending($gdimg_dropshadow_temp, true);
- for ($x = 0; $x < ImageSX($gdimg); $x++) {
- for ($y = 0; $y < ImageSY($gdimg); $y++) {
- if ($PixelMap[$x][$y]['alpha'] < 127) {
- $thisColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_dropshadow_temp, $PixelMap[$x][$y]['red'], $PixelMap[$x][$y]['green'], $PixelMap[$x][$y]['blue'], $PixelMap[$x][$y]['alpha']);
- ImageSetPixel($gdimg_dropshadow_temp, $x, $y, $thisColor);
- }
- }
- }
+ if ($alpha <= 0) {
+ // invisible shadow, nothing to do
+ return true;
+ }
+ if ($distance <= 0) {
+ // shadow completely obscured by source image, nothing to do
+ return true;
+ }
- ImageSaveAlpha($gdimg, true);
- ImageAlphaBlending($gdimg, false);
- //$this->is_alpha = true;
- $transparent2 = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, 0, 0, 0, 127);
- ImageFilledRectangle($gdimg, 0, 0, ImageSX($gdimg), ImageSY($gdimg), $transparent2);
- ImageCopyResampled($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg), ImageSX($gdimg_dropshadow_temp), ImageSY($gdimg_dropshadow_temp));
+ $width_shadow = cos(deg2rad($angle)) * ($distance + $width);
+ $height_shadow = sin(deg2rad($angle)) * ($distance + $width);
- ImageDestroy($gdimg_dropshadow_temp);
- }
- return true;
- }
+ $scaling = min(ImageSX($gdimg) / (ImageSX($gdimg) + abs($width_shadow)), ImageSY($gdimg) / (ImageSY($gdimg) + abs($height_shadow)));
+ for ($i = 0; $i < $width; $i++) {
+ $WidthAlpha[$i] = (abs(($width / 2) - $i) / $width);
+ $Offset['x'] = cos(deg2rad($angle)) * ($distance + $i);
+ $Offset['y'] = sin(deg2rad($angle)) * ($distance + $i);
+ }
- function EdgeDetect(&$gdimg) {
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- if (ImageFilter($gdimg, IMG_FILTER_EDGEDETECT)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_EDGEDETECT)', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
- // currently not implemented "the hard way"
- $this->DebugMessage('FAILED: phpthumb_filters::EdgeDetect($gdimg) [function not implemented]', __FILE__, __LINE__);
- return false;
- }
+ $tempImageWidth = ImageSX($gdimg) + abs($Offset['x']);
+ $tempImageHeight = ImageSY($gdimg) + abs($Offset['y']);
+ if ($gdimg_dropshadow_temp = phpthumb_functions::ImageCreateFunction($tempImageWidth, $tempImageHeight)) {
- function Elipse($gdimg) {
- if (phpthumb_functions::gd_version() < 2) {
- return false;
- }
- // generate mask at twice desired resolution and downsample afterwards for easy antialiasing
- if ($gdimg_elipsemask_double = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg) * 2, ImageSY($gdimg) * 2)) {
- if ($gdimg_elipsemask = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) {
+ ImageAlphaBlending($gdimg_dropshadow_temp, false);
+ ImageSaveAlpha($gdimg_dropshadow_temp, true);
+ $transparent1 = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_dropshadow_temp, 0, 0, 0, 127);
+ ImageFill($gdimg_dropshadow_temp, 0, 0, $transparent1);
- $color_transparent = ImageColorAllocate($gdimg_elipsemask_double, 255, 255, 255);
- ImageFilledEllipse($gdimg_elipsemask_double, ImageSX($gdimg), ImageSY($gdimg), (ImageSX($gdimg) - 1) * 2, (ImageSY($gdimg) - 1) * 2, $color_transparent);
- ImageCopyResampled($gdimg_elipsemask, $gdimg_elipsemask_double, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg), ImageSX($gdimg) * 2, ImageSY($gdimg) * 2);
+ for ($x = 0; $x < ImageSX($gdimg); $x++) {
+ for ($y = 0; $y < ImageSY($gdimg); $y++) {
+ $PixelMap[$x][$y] = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
+ }
+ }
+ for ($x = 0; $x < $tempImageWidth; $x++) {
+ for ($y = 0; $y < $tempImageHeight; $y++) {
+ //for ($i = 0; $i < $width; $i++) {
+ for ($i = 0; $i < 1; $i++) {
+ if (!isset($PixelMap[$x][$y]['alpha']) || ($PixelMap[$x][$y]['alpha'] > 0)) {
+ if (isset($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']) && ($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha'] < 127)) {
+ $thisColor = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor, false, $PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']);
+ ImageSetPixel($gdimg_dropshadow_temp, $x, $y, $thisColor);
+ }
+ }
+ }
+ }
+ }
- phpthumb_filters::ApplyMask($gdimg_elipsemask, $gdimg);
- ImageDestroy($gdimg_elipsemask);
- return true;
+ ImageAlphaBlending($gdimg_dropshadow_temp, true);
+ for ($x = 0; $x < ImageSX($gdimg); $x++) {
+ for ($y = 0; $y < ImageSY($gdimg); $y++) {
+ if ($PixelMap[$x][$y]['alpha'] < 127) {
+ $thisColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_dropshadow_temp, $PixelMap[$x][$y]['red'], $PixelMap[$x][$y]['green'], $PixelMap[$x][$y]['blue'], $PixelMap[$x][$y]['alpha']);
+ ImageSetPixel($gdimg_dropshadow_temp, $x, $y, $thisColor);
+ }
+ }
+ }
- } else {
- $this->DebugMessage('$gdimg_elipsemask = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__);
- }
- ImageDestroy($gdimg_elipsemask_double);
- } else {
- $this->DebugMessage('$gdimg_elipsemask_double = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__);
- }
- return false;
- }
+ ImageSaveAlpha($gdimg, true);
+ ImageAlphaBlending($gdimg, false);
+ //$this->is_alpha = true;
+ $transparent2 = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, 0, 0, 0, 127);
+ ImageFilledRectangle($gdimg, 0, 0, ImageSX($gdimg), ImageSY($gdimg), $transparent2);
+ ImageCopyResampled($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg), ImageSX($gdimg_dropshadow_temp), ImageSY($gdimg_dropshadow_temp));
+ ImageDestroy($gdimg_dropshadow_temp);
+ }
- function Emboss(&$gdimg) {
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- if (ImageFilter($gdimg, IMG_FILTER_EMBOSS)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_EMBOSS)', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
- // currently not implemented "the hard way"
- $this->DebugMessage('FAILED: phpthumb_filters::Emboss($gdimg) [function not implemented]', __FILE__, __LINE__);
- return false;
- }
+ return true;
+ }
- function Flip(&$gdimg, $x=false, $y=false) {
- if (!$x && !$y) {
- return false;
- }
- if ($tempImage = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) {
- if ($x) {
- ImageCopy($tempImage, $gdimg, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg));
- for ($x = 0; $x < ImageSX($gdimg); $x++) {
- ImageCopy($gdimg, $tempImage, ImageSX($gdimg) - 1 - $x, 0, $x, 0, 1, ImageSY($gdimg));
- }
- }
- if ($y) {
- ImageCopy($tempImage, $gdimg, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg));
- for ($y = 0; $y < ImageSY($gdimg); $y++) {
- ImageCopy($gdimg, $tempImage, 0, ImageSY($gdimg) - 1 - $y, 0, $y, ImageSX($gdimg), 1);
- }
- }
- ImageDestroy($tempImage);
- }
- return true;
- }
+ function EdgeDetect(&$gdimg) {
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ if (ImageFilter($gdimg, IMG_FILTER_EDGEDETECT)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_EDGEDETECT)', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
+ // currently not implemented "the hard way"
+ $this->DebugMessage('FAILED: phpthumb_filters::EdgeDetect($gdimg) [function not implemented]', __FILE__, __LINE__);
+ return false;
+ }
- function Frame(&$gdimg, $frame_width, $edge_width, $hexcolor_frame, $hexcolor1, $hexcolor2) {
- $frame_width = ($frame_width ? $frame_width : 5);
- $edge_width = ($edge_width ? $edge_width : 1);
- $hexcolor_frame = ($hexcolor_frame ? $hexcolor_frame : 'CCCCCC');
- $hexcolor1 = ($hexcolor1 ? $hexcolor1 : 'FFFFFF');
- $hexcolor2 = ($hexcolor2 ? $hexcolor2 : '000000');
- $color_frame = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor_frame);
- $color1 = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor1);
- $color2 = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor2);
- for ($i = 0; $i < $edge_width; $i++) {
- // outer bevel
- ImageLine($gdimg, $i, $i, $i, ImageSY($gdimg) - $i, $color1); // left
- ImageLine($gdimg, $i, $i, ImageSX($gdimg) - $i, $i, $color1); // top
- ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i, ImageSX($gdimg) - $i, $i, $color2); // right
- ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i, $i, ImageSY($gdimg) - $i, $color2); // bottom
- }
- for ($i = 0; $i < $frame_width; $i++) {
- // actual frame
- ImageRectangle($gdimg, $edge_width + $i, $edge_width + $i, ImageSX($gdimg) - $edge_width - $i, ImageSY($gdimg) - $edge_width - $i, $color_frame);
- }
- for ($i = 0; $i < $edge_width; $i++) {
- // inner bevel
- ImageLine($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $color2); // left
- ImageLine($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, ImageSX($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color2); // top
- ImageLine($gdimg, ImageSX($gdimg) - $frame_width - $edge_width - $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, ImageSX($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color1); // right
- ImageLine($gdimg, ImageSX($gdimg) - $frame_width - $edge_width - $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $color1); // bottom
- }
- return true;
- }
+ function Elipse($gdimg) {
+ if (phpthumb_functions::gd_version() < 2) {
+ return false;
+ }
+ // generate mask at twice desired resolution and downsample afterwards for easy antialiasing
+ if ($gdimg_elipsemask_double = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg) * 2, ImageSY($gdimg) * 2)) {
+ if ($gdimg_elipsemask = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) {
+ $color_transparent = ImageColorAllocate($gdimg_elipsemask_double, 255, 255, 255);
+ ImageFilledEllipse($gdimg_elipsemask_double, ImageSX($gdimg), ImageSY($gdimg), (ImageSX($gdimg) - 1) * 2, (ImageSY($gdimg) - 1) * 2, $color_transparent);
+ ImageCopyResampled($gdimg_elipsemask, $gdimg_elipsemask_double, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg), ImageSX($gdimg) * 2, ImageSY($gdimg) * 2);
- function Gamma(&$gdimg, $amount) {
- if (number_format($amount, 4) == '1.0000') {
- return true;
- }
- return ImageGammaCorrect($gdimg, 1.0, $amount);
- }
+ phpthumb_filters::ApplyMask($gdimg_elipsemask, $gdimg);
+ ImageDestroy($gdimg_elipsemask);
+ return true;
- function Grayscale(&$gdimg) {
- if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
- if (ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)) {
- return true;
- }
- $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)', __FILE__, __LINE__);
- // fall through and try it the hard way
- }
- return phpthumb_filters::Colorize($gdimg, 100, 'gray');
- }
+ } else {
+ $this->DebugMessage('$gdimg_elipsemask = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__);
+ }
+ ImageDestroy($gdimg_elipsemask_double);
+ } else {
+ $this->DebugMessage('$gdimg_elipsemask_double = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__);
+ }
+ return false;
+ }
- function HistogramAnalysis(&$gdimg, $calculateGray=false) {
- $ImageSX = ImageSX($gdimg);
- $ImageSY = ImageSY($gdimg);
- for ($x = 0; $x < $ImageSX; $x++) {
- for ($y = 0; $y < $ImageSY; $y++) {
- $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
- @$Analysis['red'][$OriginalPixel['red']]++;
- @$Analysis['green'][$OriginalPixel['green']]++;
- @$Analysis['blue'][$OriginalPixel['blue']]++;
- @$Analysis['alpha'][$OriginalPixel['alpha']]++;
- if ($calculateGray) {
- $GrayPixel = phpthumb_functions::GrayscalePixel($OriginalPixel);
- @$Analysis['gray'][$GrayPixel['red']]++;
- }
- }
- }
- $keys = array('red', 'green', 'blue', 'alpha');
- if ($calculateGray) {
- $keys[] = 'gray';
- }
- foreach ($keys as $dummy => $key) {
- ksort($Analysis[$key]);
- }
- return $Analysis;
- }
+ function Emboss(&$gdimg) {
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ if (ImageFilter($gdimg, IMG_FILTER_EMBOSS)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_EMBOSS)', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
+ // currently not implemented "the hard way"
+ $this->DebugMessage('FAILED: phpthumb_filters::Emboss($gdimg) [function not implemented]', __FILE__, __LINE__);
- function HistogramStretch(&$gdimg, $band='*', $method=0, $threshold=0.1) {
- // equivalent of "Auto Contrast" in Adobe Photoshop
- // method 0 stretches according to RGB colors. Gives a more conservative stretch.
- // method 1 band stretches according to grayscale which is color-biased (59% green, 30% red, 11% blue). May give a punchier / more aggressive stretch, possibly appearing over-saturated
- $Analysis = phpthumb_filters::HistogramAnalysis($gdimg, true);
- $keys = array('r'=>'red', 'g'=>'green', 'b'=>'blue', 'a'=>'alpha', '*'=>(($method == 0) ? 'all' : 'gray'));
- $band = substr($band, 0, 1);
- if (!isset($keys[$band])) {
- return false;
- }
- $key = $keys[$band];
+ return false;
+ }
- // If the absolute brightest and darkest pixels are used then one random
- // pixel in the image could throw off the whole system. Instead, count up/down
- // from the limit and allow <threshold> (default = 0.1%) of brightest/darkest
- // pixels to be clipped to min/max
- $threshold = floatval($threshold) / 100;
- $clip_threshold = ImageSX($gdimg) * ImageSX($gdimg) * $threshold;
- //if ($min >= 0) {
- // $range_min = min($min, 255);
- //} else {
- $countsum = 0;
- for ($i = 0; $i <= 255; $i++) {
- if ($method == 0) {
- $countsum = max(@$Analysis['red'][$i], @$Analysis['green'][$i], @$Analysis['blue'][$i]);
- } else {
- $countsum += @$Analysis[$key][$i];
- }
- if ($countsum >= $clip_threshold) {
- $range_min = $i - 1;
- break;
- }
- }
- $range_min = max($range_min, 0);
- //}
- //if ($max > 0) {
- // $range_max = max($max, 255);
- //} else {
- $countsum = 0;
- for ($i = 255; $i >= 0; $i--) {
- if ($method == 0) {
- $countsum = max(@$Analysis['red'][$i], @$Analysis['green'][$i], @$Analysis['blue'][$i]);
- } else {
- $countsum += @$Analysis[$key][$i];
- }
- if ($countsum >= $clip_threshold) {
- $range_max = $i + 1;
- break;
- }
- }
- $range_max = min($range_max, 255);
- //}
- $range_scale = (($range_max == $range_min) ? 1 : (255 / ($range_max - $range_min)));
- if (($range_min == 0) && ($range_max == 255)) {
- // no adjustment neccesary - don't waste CPU time!
- return true;
- }
- $ImageSX = ImageSX($gdimg);
- $ImageSY = ImageSY($gdimg);
- for ($x = 0; $x < $ImageSX; $x++) {
- for ($y = 0; $y < $ImageSY; $y++) {
- $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
- if ($band == '*') {
- $new['red'] = min(255, max(0, ($OriginalPixel['red'] - $range_min) * $range_scale));
- $new['green'] = min(255, max(0, ($OriginalPixel['green'] - $range_min) * $range_scale));
- $new['blue'] = min(255, max(0, ($OriginalPixel['blue'] - $range_min) * $range_scale));
- $new['alpha'] = min(255, max(0, ($OriginalPixel['alpha'] - $range_min) * $range_scale));
- } else {
- $new = $OriginalPixel;
- $new[$key] = min(255, max(0, ($OriginalPixel[$key] - $range_min) * $range_scale));
- }
- $newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, $new['red'], $new['green'], $new['blue'], $new['alpha']);
- ImageSetPixel($gdimg, $x, $y, $newColor);
- }
- }
+ function Flip(&$gdimg, $x=false, $y=false) {
+ if (!$x && !$y) {
+ return false;
+ }
+ if ($tempImage = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) {
+ if ($x) {
+ ImageCopy($tempImage, $gdimg, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg));
+ for ($x = 0; $x < ImageSX($gdimg); $x++) {
+ ImageCopy($gdimg, $tempImage, ImageSX($gdimg) - 1 - $x, 0, $x, 0, 1, ImageSY($gdimg));
+ }
+ }
+ if ($y) {
+ ImageCopy($tempImage, $gdimg, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg));
+ for ($y = 0; $y < ImageSY($gdimg); $y++) {
+ ImageCopy($gdimg, $tempImage, 0, ImageSY($gdimg) - 1 - $y, 0, $y, ImageSX($gdimg), 1);
+ }
+ }
+ ImageDestroy($tempImage);
+ }
- return true;
- }
+ return true;
+ }
- function HistogramOverlay(&$gdimg, $bands='*', $colors='', $width=0.25, $height=0.25, $alignment='BR', $opacity=50, $margin_x=5, $margin_y=null) {
- $margin_y = (is_null($margin_y) ? $margin_x : $margin_y);
+ function Frame(&$gdimg, $frame_width, $edge_width, $hexcolor_frame, $hexcolor1, $hexcolor2) {
+ $frame_width = ($frame_width ? $frame_width : 5);
+ $edge_width = ($edge_width ? $edge_width : 1);
+ $hexcolor_frame = ($hexcolor_frame ? $hexcolor_frame : 'CCCCCC');
+ $hexcolor1 = ($hexcolor1 ? $hexcolor1 : 'FFFFFF');
+ $hexcolor2 = ($hexcolor2 ? $hexcolor2 : '000000');
- $Analysis = phpthumb_filters::HistogramAnalysis($gdimg, true);
- $histW = round(($width > 1) ? min($width, ImageSX($gdimg)) : ImageSX($gdimg) * $width);
- $histH = round(($width > 1) ? min($width, ImageSX($gdimg)) : ImageSX($gdimg) * $width);
- if ($gdHist = ImageCreateTrueColor($histW, $histH)) {
- $color_back = phpthumb_functions::ImageColorAllocateAlphaSafe($gdHist, 0, 0, 0, 127);
- ImageFilledRectangle($gdHist, 0, 0, $histW, $histH, $color_back);
- ImageAlphaBlending($gdHist, false);
- ImageSaveAlpha($gdHist, true);
+ $color_frame = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor_frame);
+ $color1 = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor1);
+ $color2 = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor2);
+ for ($i = 0; $i < $edge_width; $i++) {
+ // outer bevel
+ ImageLine($gdimg, $i, $i, $i, ImageSY($gdimg) - $i, $color1); // left
+ ImageLine($gdimg, $i, $i, ImageSX($gdimg) - $i, $i, $color1); // top
+ ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i, ImageSX($gdimg) - $i, $i, $color2); // right
+ ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i, $i, ImageSY($gdimg) - $i, $color2); // bottom
+ }
+ for ($i = 0; $i < $frame_width; $i++) {
+ // actual frame
+ ImageRectangle($gdimg, $edge_width + $i, $edge_width + $i, ImageSX($gdimg) - $edge_width - $i, ImageSY($gdimg) - $edge_width - $i, $color_frame);
+ }
+ for ($i = 0; $i < $edge_width; $i++) {
+ // inner bevel
+ ImageLine($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $color2); // left
+ ImageLine($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, ImageSX($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color2); // top
+ ImageLine($gdimg, ImageSX($gdimg) - $frame_width - $edge_width - $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, ImageSX($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color1); // right
+ ImageLine($gdimg, ImageSX($gdimg) - $frame_width - $edge_width - $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $color1); // bottom
+ }
- $HistogramTempWidth = 256;
- $HistogramTempHeight = 100;
- if ($gdHistTemp = ImageCreateTrueColor($HistogramTempWidth, $HistogramTempHeight)) {
- $color_back_temp = phpthumb_functions::ImageColorAllocateAlphaSafe($gdHistTemp, 255, 0, 255, 127);
- ImageAlphaBlending($gdHistTemp, false);
- ImageSaveAlpha($gdHistTemp, true);
- ImageFilledRectangle($gdHistTemp, 0, 0, ImageSX($gdHistTemp), ImageSY($gdHistTemp), $color_back_temp);
+ return true;
+ }
- $DefaultColors = array('r'=>'FF0000', 'g'=>'00FF00', 'b'=>'0000FF', 'a'=>'999999', '*'=>'FFFFFF');
- $Colors = explode(';', $colors);
- $BandsToGraph = array_unique(preg_split('##', $bands));
- $keys = array('r'=>'red', 'g'=>'green', 'b'=>'blue', 'a'=>'alpha', '*'=>'gray');
- foreach ($BandsToGraph as $key => $band) {
- if (!isset($keys[$band])) {
- continue;
- }
- $PeakValue = max($Analysis[$keys[$band]]);
- $thisColor = phpthumb_functions::ImageHexColorAllocate($gdHistTemp, phpthumb_functions::IsHexColor(@$Colors[$key]) ? $Colors[$key] : $DefaultColors[$band]);
- for ($x = 0; $x < $HistogramTempWidth; $x++) {
- ImageLine($gdHistTemp, $x, $HistogramTempHeight - 1, $x, $HistogramTempHeight - 1 - round(@$Analysis[$keys[$band]][$x] / $PeakValue * $HistogramTempHeight), $thisColor);
- }
- ImageLine($gdHistTemp, 0, $HistogramTempHeight - 1, $HistogramTempWidth - 1, $HistogramTempHeight - 1, $thisColor);
- ImageLine($gdHistTemp, 0, $HistogramTempHeight - 2, $HistogramTempWidth - 1, $HistogramTempHeight - 2, $thisColor);
- }
- ImageCopyResampled($gdHist, $gdHistTemp, 0, 0, 0, 0, ImageSX($gdHist), ImageSY($gdHist), ImageSX($gdHistTemp), ImageSY($gdHistTemp));
- ImageDestroy($gdHistTemp);
- } else {
- return false;
- }
- phpthumb_filters::WatermarkOverlay($gdimg, $gdHist, $alignment, $opacity, $margin_x, $margin_y);
- ImageDestroy($gdHist);
- return true;
- }
- return false;
- }
+ function Gamma(&$gdimg, $amount) {
+ if (number_format($amount, 4) == '1.0000') {
+ return true;
+ }
+ return ImageGammaCorrect($gdimg, 1.0, $amount);
+ }
- function ImageBorder(&$gdimg, $border_width, $radius_x, $radius_y, $hexcolor_border) {
- $border_width = ($border_width ? $border_width : 1);
- $radius_x = ($radius_x ? $radius_x : 0);
- $radius_y = ($radius_y ? $radius_y : 0);
- $output_width = ImageSX($gdimg);
- $output_height = ImageSY($gdimg);
+ function Grayscale(&$gdimg) {
+ if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
+ if (ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)) {
+ return true;
+ }
+ $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)', __FILE__, __LINE__);
+ // fall through and try it the hard way
+ }
- list($new_width, $new_height) = phpthumb_functions::ProportionalResize($output_width, $output_height, $output_width - max($border_width * 2, $radius_x), $output_height - max($border_width * 2, $radius_y));
- $offset_x = ($radius_x ? $output_width - $new_width - $radius_x : 0);
- $offset_y = ($radius_y ? $output_height - $new_height - $radius_y : 0);
+ return phpthumb_filters::Colorize($gdimg, 100, 'gray');
+ }
+
+ function HistogramAnalysis(&$gdimg, $calculateGray=false) {
+ $ImageSX = ImageSX($gdimg);
+ $ImageSY = ImageSY($gdimg);
+ for ($x = 0; $x < $ImageSX; $x++) {
+ for ($y = 0; $y < $ImageSY; $y++) {
+ $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y);
+ @$Analysis['red'][$OriginalPixel['red']]++;
+ @$Analysis['green'][$OriginalPixel['green']]++;
+ @$Analysis['blue'][$OriginalPixel['blue']]++;
+ @$Analysis['alpha'][$OriginalPixel['alpha']]++;
+ if ($calculateGray) {
+ $GrayPixel = phpthumb_functions::GrayscalePixel($OriginalPixel);
+ @$Analysis['gray'][$GrayPixel['red']]++;
+ }
+ }
+ }
+ $keys = array('red', 'green', 'blue', 'alpha');
+ if ($calculateGray) {
+ $keys[] = 'gray';
+ }
+ foreach ($keys as $dummy => $key) {
+ ksort($Analysis[$key]);
+ }
+
+ return $Analysis;
+ }
+
+
+ function HistogramStretch(&$gdimg, $band='*', $method=0, $threshold=0.1) {
+ // equivalent of "Auto Contrast" in Adobe Photoshop
+ // method 0 stretches according to RGB colors. Gives a more conservative stretch.
+ // method 1 band stretches according to grayscale which is color-biased (59% green, 30% red, 11% blue). May give a punchier / more aggressive stretch, possibly appearing over-saturated
+ $Analysis = phpthumb_filters::HistogramAnalysis($gdimg, true);
+ $keys = array('r'=>'red', 'g'=>'green', 'b'=>'blue', 'a'=>'alpha', '*'=>(($method == 0) ? 'all' : 'gray'));
+ $band = substr($band, 0, 1);
+ if (!isset($keys[$band])) {
+ return false;
+ }
+ $key = $keys[$band];
+
+ // If the absolute brightest and darkest pixels are used then one random
+ // pixel in the image could throw off the whole system. Instead, count up/down
+ // from the limit and allow <threshold> (default = 0.1%) of brightest/darkest
+ // pixels to be clipped to min/max
+ $threshold = floatval($threshold) / 100;
+ $clip_threshold = ImageSX($gdimg) * ImageSX($gdimg) * $threshold;
+ //if ($min >= 0) {
+ // $range_min = min($min, 255);
+ //} else {
+ $countsum = 0;
+ for ($i = 0; $i <= 255; $i++) {
+ if ($method == 0) {
+ $countsum = max(@$Analysis['red'][$i], @$Analysis['green'][$i], @$Analysis['blue'][$i]);
+ } else {
+ $countsum += @$Analysis[$key][$i];
+ }
+ if ($countsum >= $clip_threshold) {
+ $range_min = $i - 1;
+ break;
+ }
+ }
+ $range_min = max($range_min, 0...
[truncated message content] |