2 //////////////////////////////////////////////////////////////
3 /// phpThumb() by James Heinrich <info@silisoftware.com> //
4 // available at http://phpthumb.sourceforge.net ///
5 //////////////////////////////////////////////////////////////
7 // phpthumb.functions.php - general support functions //
9 //////////////////////////////////////////////////////////////
11 class phpthumb_functions {
13 function user_function_exists($functionname) {
14 if (function_exists('get_defined_functions')) {
15 static $get_defined_functions = array();
16 if (empty($get_defined_functions)) {
17 $get_defined_functions = get_defined_functions();
19 return in_array(strtolower($functionname), $get_defined_functions['user']);
21 return function_exists($functionname);
25 function builtin_function_exists($functionname) {
26 if (function_exists('get_defined_functions')) {
27 static $get_defined_functions = array();
28 if (empty($get_defined_functions)) {
29 $get_defined_functions = get_defined_functions();
31 return in_array(strtolower($functionname), $get_defined_functions['internal']);
33 return function_exists($functionname);
37 function version_compare_replacement_sub($version1, $version2, $operator='') {
38 // If you specify the third optional operator argument, you can test for a particular relationship.
39 // The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively.
40 // Using this argument, the function will return 1 if the relationship is the one specified by the operator, 0 otherwise.
42 // If a part contains special version strings these are handled in the following order: dev < (alpha = a) < (beta = b) < RC < pl
43 static $versiontype_lookup = array();
44 if (empty($versiontype_lookup)) {
45 $versiontype_lookup['dev'] = 10001;
46 $versiontype_lookup['a'] = 10002;
47 $versiontype_lookup['alpha'] = 10002;
48 $versiontype_lookup['b'] = 10003;
49 $versiontype_lookup['beta'] = 10003;
50 $versiontype_lookup['RC'] = 10004;
51 $versiontype_lookup['pl'] = 10005;
53 if (isset($versiontype_lookup[$version1])) {
54 $version1 = $versiontype_lookup[$version1];
56 if (isset($versiontype_lookup[$version2])) {
57 $version2 = $versiontype_lookup[$version2];
63 return intval($version1 < $version2);
67 return intval($version1 <= $version2);
71 return intval($version1 > $version2);
75 return intval($version1 >= $version2);
80 return intval($version1 == $version2);
85 return intval($version1 != $version2);
88 if ($version1 == $version2) {
90 } elseif ($version1 < $version2) {
97 function version_compare_replacement($version1, $version2, $operator='') {
98 if (function_exists('version_compare')) {
99 // built into PHP v4.1.0+
100 return version_compare($version1, $version2, $operator);
103 // The function first replaces _, - and + with a dot . in the version strings
104 $version1 = strtr($version1, '_-+', '...');
105 $version2 = strtr($version2, '_-+', '...');
107 // and also inserts dots . before and after any non number so that for example '4.3.2RC1' becomes '4.3.2.RC.1'.
108 // Then it splits the results like if you were using explode('.',$ver). Then it compares the parts starting from left to right.
109 $version1 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version1);
110 $version2 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version2);
112 $parts1 = explode('.', $version1);
113 $parts2 = explode('.', $version1);
114 $parts_count = max(count($parts1), count($parts2));
115 for ($i = 0; $i < $parts_count; $i++) {
116 $comparison = phpthumb_functions::version_compare_replacement_sub($version1, $version2, $operator);
117 if ($comparison != 0) {
125 function phpinfo_array() {
126 static $phpinfo_array = array();
127 if (empty($phpinfo_array)) {
130 $phpinfo = ob_get_contents();
132 $phpinfo_array = explode("\n", $phpinfo);
134 return $phpinfo_array;
138 function exif_info() {
139 static $exif_info = array();
140 if (empty($exif_info)) {
141 // based on code by johnschaefer at gmx dot de
142 // from PHP help on gd_info()
144 'EXIF Support' => '',
145 'EXIF Version' => '',
146 'Supported EXIF Version' => '',
147 'Supported filetypes' => ''
149 $phpinfo_array = phpthumb_functions::phpinfo_array();
150 foreach ($phpinfo_array as $dummy => $line) {
151 $line = trim(strip_tags($line));
152 foreach ($exif_info as $key => $value) {
153 if (strpos($line, $key) === 0) {
154 $newvalue = trim(str_replace($key, '', $line));
155 $exif_info[$key] = $newvalue;
164 function ImageTypeToMIMEtype($imagetype) {
165 if (function_exists('image_type_to_mime_type') && ($imagetype >= 1) && ($imagetype <= 16)) {
167 return image_type_to_mime_type($imagetype);
169 static $image_type_to_mime_type = array(
170 1 => 'image/gif', // IMAGETYPE_GIF
171 2 => 'image/jpeg', // IMAGETYPE_JPEG
172 3 => 'image/png', // IMAGETYPE_PNG
173 4 => 'application/x-shockwave-flash', // IMAGETYPE_SWF
174 5 => 'image/psd', // IMAGETYPE_PSD
175 6 => 'image/bmp', // IMAGETYPE_BMP
176 7 => 'image/tiff', // IMAGETYPE_TIFF_II (intel byte order)
177 8 => 'image/tiff', // IMAGETYPE_TIFF_MM (motorola byte order)
178 9 => 'application/octet-stream', // IMAGETYPE_JPC
179 10 => 'image/jp2', // IMAGETYPE_JP2
180 11 => 'application/octet-stream', // IMAGETYPE_JPX
181 12 => 'application/octet-stream', // IMAGETYPE_JB2
182 13 => 'application/x-shockwave-flash', // IMAGETYPE_SWC
183 14 => 'image/iff', // IMAGETYPE_IFF
184 15 => 'image/vnd.wap.wbmp', // IMAGETYPE_WBMP
185 16 => 'image/xbm', // IMAGETYPE_XBM
187 'gif' => 'image/gif', // IMAGETYPE_GIF
188 'jpg' => 'image/jpeg', // IMAGETYPE_JPEG
189 'jpeg' => 'image/jpeg', // IMAGETYPE_JPEG
190 'png' => 'image/png', // IMAGETYPE_PNG
191 'bmp' => 'image/bmp', // IMAGETYPE_BMP
192 'ico' => 'image/x-icon',
195 return (isset($image_type_to_mime_type[$imagetype]) ? $image_type_to_mime_type[$imagetype] : false);
199 function HexCharDisplay($string) {
200 $len = strlen($string);
202 for ($i = 0; $i < $len; $i++) {
203 $output .= ' 0x'.str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
209 function IsHexColor($HexColorString) {
210 return eregi('^[0-9A-F]{6}$', $HexColorString);
214 function ImageColorAllocateAlphaSafe(&$gdimg_hexcolorallocate, $R, $G, $B, $alpha=false) {
215 if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && ($alpha !== false)) {
216 return ImageColorAllocateAlpha($gdimg_hexcolorallocate, $R, $G, $B, intval($alpha));
218 return ImageColorAllocate($gdimg_hexcolorallocate, $R, $G, $B);
222 function ImageHexColorAllocate(&$gdimg_hexcolorallocate, $HexColorString, $dieOnInvalid=false, $alpha=false) {
223 if (!is_resource($gdimg_hexcolorallocate)) {
224 die('$gdimg_hexcolorallocate is not a GD resource in ImageHexColorAllocate()');
226 if (phpthumb_functions::IsHexColor($HexColorString)) {
227 $R = hexdec(substr($HexColorString, 0, 2));
228 $G = hexdec(substr($HexColorString, 2, 2));
229 $B = hexdec(substr($HexColorString, 4, 2));
230 return phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_hexcolorallocate, $R, $G, $B, $alpha);
233 die('Invalid hex color string: "'.$HexColorString.'"');
235 return ImageColorAllocate($gdimg_hexcolorallocate, 0x00, 0x00, 0x00);
239 function HexColorXOR($hexcolor) {
240 return strtoupper(str_pad(dechex(~hexdec($hexcolor) & 0xFFFFFF), 6, '0', STR_PAD_LEFT));
244 function GetPixelColor(&$img, $x, $y) {
245 if (!is_resource($img)) {
248 return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
252 function GrayscaleValue($r, $g, $b) {
253 return round(($r * 0.30) + ($g * 0.59) + ($b * 0.11));
257 function GrayscalePixel($OriginalPixel) {
258 $gray = phpthumb_functions::GrayscaleValue($OriginalPixel['red'], $OriginalPixel['green'], $OriginalPixel['blue']);
259 return array('red'=>$gray, 'green'=>$gray, 'blue'=>$gray);
263 function GrayscalePixelRGB($rgb) {
264 $r = ($rgb >> 16) & 0xFF;
265 $g = ($rgb >> 8) & 0xFF;
267 return ($r * 0.299) + ($g * 0.587) + ($b * 0.114);
271 function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {
272 // ron at korving dot demon dot nl
273 // http://www.php.net/imagecopyresampled
275 $scaleX = ($src_w - 1) / $dst_w;
276 $scaleY = ($src_h - 1) / $dst_h;
278 $scaleX2 = $scaleX / 2.0;
279 $scaleY2 = $scaleY / 2.0;
281 $isTrueColor = ImageIsTrueColor($src_img);
283 for ($y = $src_y; $y < $src_y + $dst_h; $y++) {
286 $siY2 = (int) $sY + $scaleY2;
288 for ($x = $src_x; $x < $src_x + $dst_w; $x++) {
291 $siX2 = (int) $sX + $scaleX2;
295 $c1 = ImageColorAt($src_img, $siX, $siY2);
296 $c2 = ImageColorAt($src_img, $siX, $siY);
297 $c3 = ImageColorAt($src_img, $siX2, $siY2);
298 $c4 = ImageColorAt($src_img, $siX2, $siY);
300 $r = (( $c1 + $c2 + $c3 + $c4 ) >> 2) & 0xFF0000;
301 $g = ((($c1 & 0x00FF00) + ($c2 & 0x00FF00) + ($c3 & 0x00FF00) + ($c4 & 0x00FF00)) >> 2) & 0x00FF00;
302 $b = ((($c1 & 0x0000FF) + ($c2 & 0x0000FF) + ($c3 & 0x0000FF) + ($c4 & 0x0000FF)) >> 2);
306 $c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY2));
307 $c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY));
308 $c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY2));
309 $c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY));
311 $r = ($c1['red'] + $c2['red'] + $c3['red'] + $c4['red'] ) << 14;
312 $g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) << 6;
313 $b = ($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue'] ) >> 2;
316 ImageSetPixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r+$g+$b);
323 function ImageCreateFunction($x_size, $y_size) {
324 $ImageCreateFunction = 'ImageCreate';
325 if (phpthumb_functions::gd_version() >= 2.0) {
326 $ImageCreateFunction = 'ImageCreateTrueColor';
328 if (!function_exists($ImageCreateFunction)) {
329 return phpthumb::ErrorImage($ImageCreateFunction.'() does not exist - no GD support?');
331 if (($x_size <= 0) || ($y_size <= 0)) {
332 return phpthumb::ErrorImage('Invalid image dimensions: '.$ImageCreateFunction.'('.$x_size.', '.$y_size.')');
334 return $ImageCreateFunction($x_size, $y_size);
338 function ImageCopyRespectAlpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct=100) {
339 for ($x = $src_x; $x < $src_w; $x++) {
340 for ($y = $src_y; $y < $src_h; $y++) {
341 $RealPixel = phpthumb_functions::GetPixelColor($dst_im, $dst_x + $x, $dst_y + $y);
342 $OverlayPixel = phpthumb_functions::GetPixelColor($src_im, $x, $y);
343 $alphapct = $OverlayPixel['alpha'] / 127;
344 $opacipct = $pct / 100;
345 $overlaypct = (1 - $alphapct) * $opacipct;
347 $newcolor = phpthumb_functions::ImageColorAllocateAlphaSafe(
349 round($RealPixel['red'] * (1 - $overlaypct)) + ($OverlayPixel['red'] * $overlaypct),
350 round($RealPixel['green'] * (1 - $overlaypct)) + ($OverlayPixel['green'] * $overlaypct),
351 round($RealPixel['blue'] * (1 - $overlaypct)) + ($OverlayPixel['blue'] * $overlaypct),
352 //$RealPixel['alpha']);
355 ImageSetPixel($dst_im, $dst_x + $x, $dst_y + $y, $newcolor);
362 function ProportionalResize($old_width, $old_height, $new_width=false, $new_height=false) {
363 $old_aspect_ratio = $old_width / $old_height;
364 if (($new_width === false) && ($new_height === false)) {
366 } elseif ($new_width === false) {
367 $new_width = $new_height * $old_aspect_ratio;
368 } elseif ($new_height === false) {
369 $new_height = $new_width / $old_aspect_ratio;
371 $new_aspect_ratio = $new_width / $new_height;
372 if ($new_aspect_ratio == $old_aspect_ratio) {
374 } elseif ($new_aspect_ratio < $old_aspect_ratio) {
376 $new_height = $new_width / $old_aspect_ratio;
377 } elseif ($new_aspect_ratio > $old_aspect_ratio) {
379 $new_width = $new_height * $old_aspect_ratio;
381 return array(round($new_width), round($new_height));
385 function SafeExec($command) {
386 static $AllowedExecFunctions = array();
387 if (empty($AllowedExecFunctions)) {
388 $AllowedExecFunctions = array('shell_exec'=>true, 'passthru'=>true, 'system'=>true, 'exec'=>true);
389 if (@ini_get('safe_mode')) {
390 $AllowedExecFunctions['shell_exec'] = false;
392 $disable_functions = explode(',', @ini_get('disable_functions'));
393 foreach ($AllowedExecFunctions as $key => $value) {
394 if (in_array($key, $disable_functions)) {
395 $AllowedExecFunctions[$key] = false;
399 foreach ($AllowedExecFunctions as $execfunction => $is_allowed) {
403 switch ($execfunction) {
406 $execfunction($command);
407 $returnvalue = ob_get_contents();
415 $returnvalue = @$execfunction($command);
424 function ApacheLookupURIarray($filename) {
425 // apache_lookup_uri() only works when PHP is installed as an Apache module.
426 if (php_sapi_name() == 'apache') {
427 $keys = array('status', 'the_request', 'status_line', 'method', 'content_type', 'handler', 'uri', 'filename', 'path_info', 'args', 'boundary', 'no_cache', 'no_local_copy', 'allowed', 'send_bodyct', 'bytes_sent', 'byterange', 'clength', 'unparsed_uri', 'mtime', 'request_time');
428 if ($apacheLookupURIobject = @apache_lookup_uri($filename)) {
429 $apacheLookupURIarray = array();
430 foreach ($keys as $dummy => $key) {
431 $apacheLookupURIarray[$key] = @$apacheLookupURIobject->$key;
433 return $apacheLookupURIarray;
440 function gd_is_bundled() {
441 static $isbundled = null;
442 if (is_null($isbundled)) {
443 $gd_info = gd_info();
444 $isbundled = (strpos($gd_info['GD Version'], 'bundled') !== false);
450 function gd_version($fullstring=false) {
451 static $cache_gd_version = array();
452 if (empty($cache_gd_version)) {
453 $gd_info = gd_info();
454 if (eregi('bundled \((.+)\)$', $gd_info['GD Version'], $matches)) {
455 $cache_gd_version[1] = $gd_info['GD Version']; // e.g. "bundled (2.0.15 compatible)"
456 $cache_gd_version[0] = (float) $matches[1]; // e.g. "2.0" (not "bundled (2.0.15 compatible)")
458 $cache_gd_version[1] = $gd_info['GD Version']; // e.g. "1.6.2 or higher"
459 $cache_gd_version[0] = (float) substr($gd_info['GD Version'], 0, 3); // e.g. "1.6" (not "1.6.2 or higher")
462 return $cache_gd_version[intval($fullstring)];
466 function filesize_remote($remotefile, $timeout=10) {
468 $url = parse_url($remotefile);
469 if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
470 fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
471 if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=')) {
472 stream_set_timeout($fp, $timeout);
475 $headerline = fgets($fp, 4096);
476 if (eregi('^Content-Length: (.*)', $headerline, $matches)) {
477 $size = intval($matches[1]);
487 function filedate_remote($remotefile, $timeout=10) {
489 $url = parse_url($remotefile);
490 if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
491 fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
492 if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=')) {
493 stream_set_timeout($fp, $timeout);
496 $headerline = fgets($fp, 4096);
497 if (eregi('^Last-Modified: (.*)', $headerline, $matches)) {
498 $date = strtotime($matches[1]) - date('Z');
508 function md5_file_safe($filename) {
509 // md5_file() doesn't exist in PHP < 4.2.0
510 if (function_exists('md5_file')) {
511 return md5_file($filename);
513 if ($fp = @fopen($filename, 'rb')) {
516 $buffer = fread($fp, 8192);
518 } while (strlen($buffer) > 0);
520 return md5($rawData);
526 function nonempty_min() {
527 $arg_list = func_get_args();
528 $acceptable = array();
529 foreach ($arg_list as $dummy => $arg) {
531 $acceptable[] = $arg;
534 return min($acceptable);
538 function LittleEndian2String($number, $minbytes=1) {
540 while ($number > 0) {
541 $intstring = $intstring.chr($number & 255);
544 return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
547 function OneOfThese() {
548 // return the first useful (non-empty/non-zero/non-false) value from those passed
549 $arg_list = func_get_args();
550 foreach ($arg_list as $key => $value) {
558 function CaseInsensitiveInArray($needle, $haystack) {
559 $needle = strtolower($needle);
560 foreach ($haystack as $key => $value) {
561 if (is_array($value)) {
563 } elseif ($needle == strtolower($value)) {
570 function SafeURLread($url, &$error) {
571 if (function_exists('curl_version')) {
573 curl_setopt($ch, CURLOPT_URL, $url);
574 curl_setopt($ch, CURLOPT_HEADER, false);
575 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
576 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
577 $rawData = curl_exec($ch);
579 if (strlen($rawData) > 0) {
582 $error .= 'CURL available but returned no data; ';
584 $error .= 'CURL unavailable; ';
586 if (@ini_get('allow_url_fopen')) {
589 if ($fp = fopen($url, 'rb')) {
591 $buffer = fread($fp, 8192);
593 } while (strlen($buffer) > 0);
596 $error = trim(strip_tags(ob_get_contents()));
602 $error .= '; "allow_url_fopen" enabled but returned no data; ';
604 $error .= '"allow_url_fopen" disabled; ';
612 if (!function_exists('gd_info')) {
613 // built into PHP v4.3.0+ (with bundled GD2 library)
615 static $gd_info = array();
616 if (empty($gd_info)) {
617 // based on code by johnschaefer at gmx dot de
618 // from PHP help on gd_info()
621 'FreeType Support' => false,
622 'FreeType Linkage' => '',
623 'T1Lib Support' => false,
624 'GIF Read Support' => false,
625 'GIF Create Support' => false,
626 'JPG Support' => false,
627 'PNG Support' => false,
628 'WBMP Support' => false,
629 'XBM Support' => false
631 $phpinfo_array = phpthumb_functions::phpinfo_array();
632 foreach ($phpinfo_array as $dummy => $line) {
633 $line = trim(strip_tags($line));
634 foreach ($gd_info as $key => $value) {
635 //if (strpos($line, $key) !== false) {
636 if (strpos($line, $key) === 0) {
637 $newvalue = trim(str_replace($key, '', $line));
638 $gd_info[$key] = $newvalue;
642 if (empty($gd_info['GD Version'])) {
643 // probable cause: "phpinfo() disabled for security reasons"
644 if (function_exists('ImageTypes')) {
645 $imagetypes = ImageTypes();
646 if ($imagetypes & IMG_PNG) {
647 $gd_info['PNG Support'] = true;
649 if ($imagetypes & IMG_GIF) {
650 $gd_info['GIF Create Support'] = true;
652 if ($imagetypes & IMG_JPG) {
653 $gd_info['JPG Support'] = true;
655 if ($imagetypes & IMG_WBMP) {
656 $gd_info['WBMP Support'] = true;
659 // to determine capability of GIF creation, try to use ImageCreateFromGIF on a 1px GIF
660 if (function_exists('ImageCreateFromGIF')) {
661 if ($tempfilename = phpthumb::phpThumb_tempnam()) {
662 if ($fp_tempfile = @fopen($tempfilename, 'wb')) {
663 fwrite($fp_tempfile, base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw==')); // very simple 1px GIF file base64-encoded as string
664 fclose($fp_tempfile);
666 // if we can convert the GIF file to a GD image then GIF create support must be enabled, otherwise it's not
667 $gd_info['GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename);
669 unlink($tempfilename);
672 if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) {
673 $gd_info['GD Version'] = '2.0.1 or higher (assumed)';
674 } elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) {
675 $gd_info['GD Version'] = '1.6.0 or higher (assumed)';
684 if (!function_exists('is_executable')) {
685 // in PHP v3+, but v5.0+ for Windows
686 function is_executable($filename) {
687 // poor substitute, but better than nothing
688 return file_exists($filename);
693 if (!function_exists('preg_quote')) {
694 // included in PHP v3.0.9+, but may be unavailable if not compiled in
695 function preg_quote($string, $delimiter='\\') {
696 static $preg_quote_array = array();
697 if (empty($preg_quote_array)) {
698 $escapeables = '.\\+*?[^]$(){}=!<>|:';
699 for ($i = 0; $i < strlen($escapeables); $i++) {
700 $strtr_preg_quote[$escapeables{$i}] = $delimiter.$escapeables{$i};
703 return strtr($string, $strtr_preg_quote);
707 if (!function_exists('file_get_contents')) {
708 // included in PHP v4.3.0+
709 function file_get_contents($filename) {
710 if (eregi('^(f|ht)tp\://', $filename)) {
711 return SafeURLread($filename);
713 if ($fp = @fopen($filename, 'rb')) {
716 $buffer = fread($fp, 8192);
718 } while (strlen($buffer) > 0);
727 if (!function_exists('file_put_contents')) {
728 // included in PHP v5.0.0+
729 function file_put_contents($filename, $filedata) {
730 if ($fp = @fopen($filename, 'wb')) {
731 fwrite($fp, $filedata);
739 if (!function_exists('imagealphablending')) {
740 // built-in function requires PHP v4.0.6+ *and* GD v2.0.1+
741 function imagealphablending(&$img, $blendmode=true) {
742 // do nothing, this function is declared here just to
743 // prevent runtime errors if GD2 is not available
748 if (!function_exists('imagesavealpha')) {
749 // built-in function requires PHP v4.3.2+ *and* GD v2.0.1+
750 function imagesavealpha(&$img, $blendmode=true) {
751 // do nothing, this function is declared here just to
752 // prevent runtime errors if GD2 is not available