function ImprovedImageRotate(&$gdimg_source, $rotate_angle = 0, $config_background_hexcolor = 'FFFFFF', $bg = null) { while ($rotate_angle < 0) { $rotate_angle += 360; } $rotate_angle = $rotate_angle % 360; if ($rotate_angle != 0) { $background_color = phpThumb_functions::ImageHexColorAllocate($gdimg_source, $config_background_hexcolor); if (phpThumb_functions::gd_version() >= 2 && !$bg && $rotate_angle % 90) { //$this->DebugMessage('Using alpha rotate', __FILE__, __LINE__); if ($gdimg_rotate_mask = phpThumb_functions::ImageCreateFunction(ImageSX($gdimg_source), ImageSY($gdimg_source))) { for ($i = 0; $i <= 255; $i++) { $color_mask[$i] = ImageColorAllocate($gdimg_rotate_mask, $i, $i, $i); } ImageFilledRectangle($gdimg_rotate_mask, 0, 0, ImageSX($gdimg_rotate_mask), ImageSY($gdimg_rotate_mask), $color_mask[255]); $imageX = ImageSX($gdimg_source); $imageY = ImageSY($gdimg_source); for ($x = 0; $x < $imageX; $x++) { for ($y = 0; $y < $imageY; $y++) { $pixelcolor = phpThumb_functions::GetPixelColor($gdimg_source, $x, $y); ImageSetPixel($gdimg_rotate_mask, $x, $y, $color_mask[255 - round($pixelcolor['alpha'] * 255 / 127)]); } } $gdimg_rotate_mask = ImageRotate($gdimg_rotate_mask, $rotate_angle, $color_mask[0]); $gdimg_source = ImageRotate($gdimg_source, $rotate_angle, $background_color); ImageAlphaBlending($gdimg_source, false); ImageSaveAlpha($gdimg_source, true); //$this->is_alpha = true; $phpThumbFilters = new phpThumb_filters(); $phpThumbFilters->phpThumbObject = $this; $phpThumbFilters->ApplyMask($gdimg_rotate_mask, $gdimg_source); ImageDestroy($gdimg_rotate_mask); } else { //$this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__); } } else { if (phpThumb_functions::gd_version() < 2) { //$this->DebugMessage('Using non-alpha rotate because gd_version is "'.phpThumb_functions::gd_version().'"', __FILE__, __LINE__); } elseif ($bg) { //$this->DebugMessage('Using non-alpha rotate because $this->bg is "'.$bg.'"', __FILE__, __LINE__); } elseif ($rotate_angle % 90) { //$this->DebugMessage('Using non-alpha rotate because ($rotate_angle % 90) = "'.($rotate_angle % 90).'"', __FILE__, __LINE__); } else { //$this->DebugMessage('Using non-alpha rotate because $this->thumbnailFormat is "'.$this->thumbnailFormat.'"', __FILE__, __LINE__); } if (ImageColorTransparent($gdimg_source) >= 0) { // ImageRotate() forgets all about an image's transparency and sets the transparent color to black // To compensate, flood-fill the transparent color of the source image with the specified background color first // then rotate and the colors should match if (!function_exists('ImageIsTrueColor') || !ImageIsTrueColor($gdimg_source)) { // convert paletted image to true-color before rotating to prevent nasty aliasing artifacts //$this->source_width = ImageSX($gdimg_source); //$this->source_height = ImageSY($gdimg_source); $gdimg_newsrc = phpThumb_functions::ImageCreateFunction(ImageSX($gdimg_source), ImageSY($gdimg_source)); $background_color = phpThumb_functions::ImageHexColorAllocate($gdimg_newsrc, $config_background_hexcolor); ImageFilledRectangle($gdimg_newsrc, 0, 0, ImageSX($gdimg_source), ImageSY($gdimg_source), phpThumb_functions::ImageHexColorAllocate($gdimg_newsrc, $config_background_hexcolor)); ImageCopy($gdimg_newsrc, $gdimg_source, 0, 0, 0, 0, ImageSX($gdimg_source), ImageSY($gdimg_source)); ImageDestroy($gdimg_source); unset($gdimg_source); $gdimg_source = $gdimg_newsrc; unset($gdimg_newsrc); } else { ImageColorSet($gdimg_source, ImageColorTransparent($gdimg_source), hexdec(substr($config_background_hexcolor, 0, 2)), hexdec(substr($config_background_hexcolor, 2, 2)), hexdec(substr($config_background_hexcolor, 4, 2))); ImageColorTransparent($gdimg_source, -1); } } $gdimg_source = ImageRotate($gdimg_source, $rotate_angle, $background_color); } } return true; }
die('failed to include_once("../phpThumb.functions.php")'); } if (!(include_once '../phpThumb.class.php')) { //ob_end_flush(); die('failed to include_once("../phpThumb.class.php")'); } //ob_end_clean(); $phpThumb = new phpThumb(); if (include_once '../phpThumb.config.php') { foreach ($PHPTHUMB_CONFIG as $key => $value) { $keyname = 'config_' . $key; $phpThumb->setParameter($keyname, $value); } } $ServerInfo['gd_string'] = phpThumb_functions::gd_version(true); $ServerInfo['gd_numeric'] = phpThumb_functions::gd_version(false); $ServerInfo['im_version'] = $phpThumb->ImageMagickVersion(); $gd_info = gd_info(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>phpThumb configuration analyzer</title> <link rel="stylesheet" type="text/css" href="/style.css" title="style sheet"> </head> <body style="background-color: #CCCCCC;"> This demo analyzes your settings (phpThumb.config.php and server/PHP) for <a href="http://phpThumb.sourceforge.net"><b>phpThumb()</b></a>.<br> <br> <table border="1">
static function ImageCreateFunction($x_size, $y_size) { $ImageCreateFunction = 'ImageCreate'; if (phpThumb_functions::gd_version() >= 2.0) { $ImageCreateFunction = 'ImageCreateTrueColor'; } if (!function_exists($ImageCreateFunction)) { return phpThumb::ErrorImage($ImageCreateFunction . '() does not exist - no GD support?'); } if ($x_size <= 0 || $y_size <= 0) { return phpThumb::ErrorImage('Invalid image dimensions: ' . $ImageCreateFunction . '(' . $x_size . ', ' . $y_size . ')'); } return $ImageCreateFunction(round($x_size), round($y_size)); }