本文整理汇总了PHP中ImageIsTrueColor函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageIsTrueColor函数的具体用法?PHP ImageIsTrueColor怎么用?PHP ImageIsTrueColor使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageIsTrueColor函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ImprovedImageRotate
public static function ImprovedImageRotate(&$gdimg_source, $rotate_angle = 0, $config_background_hexcolor = 'FFFFFF', $bg = null, &$phpThumbObject)
{
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->phpThumbObject = $phpThumbObject;
$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;
}
示例2: ImageCopyResampleBicubic
function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
// ron at korving dot demon dot nl
// http://www.php.net/imagecopyresampled
$scaleX = ($src_w - 1) / $dst_w;
$scaleY = ($src_h - 1) / $dst_h;
$scaleX2 = $scaleX / 2.0;
$scaleY2 = $scaleY / 2.0;
$isTrueColor = ImageIsTrueColor($src_img);
for ($y = $src_y; $y < $src_y + $dst_h; $y++) {
$sY = $y * $scaleY;
$siY = (int) $sY;
$siY2 = (int) $sY + $scaleY2;
for ($x = $src_x; $x < $src_x + $dst_w; $x++) {
$sX = $x * $scaleX;
$siX = (int) $sX;
$siX2 = (int) $sX + $scaleX2;
if ($isTrueColor) {
$c1 = ImageColorAt($src_img, $siX, $siY2);
$c2 = ImageColorAt($src_img, $siX, $siY);
$c3 = ImageColorAt($src_img, $siX2, $siY2);
$c4 = ImageColorAt($src_img, $siX2, $siY);
$r = $c1 + $c2 + $c3 + $c4 >> 2 & 0xff0000;
$g = ($c1 & 0xff00) + ($c2 & 0xff00) + ($c3 & 0xff00) + ($c4 & 0xff00) >> 2 & 0xff00;
$b = ($c1 & 0xff) + ($c2 & 0xff) + ($c3 & 0xff) + ($c4 & 0xff) >> 2;
} else {
$c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY2));
$c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY));
$c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY2));
$c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY));
$r = $c1['red'] + $c2['red'] + $c3['red'] + $c4['red'] << 14;
$g = $c1['green'] + $c2['green'] + $c3['green'] + $c4['green'] << 6;
$b = $c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue'] >> 2;
}
ImageSetPixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r + $g + $b);
}
}
return true;
}
示例3: GD2ICOstring
function GD2ICOstring(&$gd_image_array)
{
foreach ($gd_image_array as $key => $gd_image) {
$ImageWidths[$key] = ImageSX($gd_image);
$ImageHeights[$key] = ImageSY($gd_image);
$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
$totalcolors[$key] = ImageColorsTotal($gd_image);
$icXOR[$key] = '';
for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
for ($x = 0; $x < $ImageWidths[$key]; $x++) {
$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
$a = round(255 * ((127 - $argb['alpha']) / 127));
$r = $argb['red'];
$g = $argb['green'];
$b = $argb['blue'];
if ($bpp[$key] == 32) {
$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
} elseif ($bpp[$key] == 24) {
$icXOR[$key] .= chr($b) . chr($g) . chr($r);
}
if ($a < 128) {
@($icANDmask[$key][$y] .= '1');
} else {
@($icANDmask[$key][$y] .= '0');
}
}
// mask bits are 32-bit aligned per scanline
while (strlen($icANDmask[$key][$y]) % 32) {
$icANDmask[$key][$y] .= '0';
}
}
$icAND[$key] = '';
foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
}
}
}
foreach ($gd_image_array as $key => $gd_image) {
$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
// BITMAPINFOHEADER - 40 bytes
$BitmapInfoHeader[$key] = '';
$BitmapInfoHeader[$key] .= "(";
// DWORD biSize;
$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);
// LONG biWidth;
// The biHeight member specifies the combined
// height of the XOR and AND masks.
$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4);
// LONG biHeight;
$BitmapInfoHeader[$key] .= "";
// WORD biPlanes;
$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "";
// wBitCount;
$BitmapInfoHeader[$key] .= "";
// DWORD biCompression;
$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);
// DWORD biSizeImage;
$BitmapInfoHeader[$key] .= "";
// LONG biXPelsPerMeter;
$BitmapInfoHeader[$key] .= "";
// LONG biYPelsPerMeter;
$BitmapInfoHeader[$key] .= "";
// DWORD biClrUsed;
$BitmapInfoHeader[$key] .= "";
// DWORD biClrImportant;
}
$icondata = "";
// idReserved; // Reserved (must be 0)
$icondata .= "";
// idType; // Resource Type (1 for icons)
$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);
// idCount; // How many images?
$dwImageOffset = 6 + count($gd_image_array) * 16;
foreach ($gd_image_array as $key => $gd_image) {
// ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)
$icondata .= chr($ImageWidths[$key]);
// bWidth; // Width, in pixels, of the image
$icondata .= chr($ImageHeights[$key]);
// bHeight; // Height, in pixels, of the image
$icondata .= chr($totalcolors[$key]);
// bColorCount; // Number of colors in image (0 if >=8bpp)
$icondata .= "";
// bReserved; // Reserved ( must be 0)
$icondata .= "";
// wPlanes; // Color Planes
$icondata .= chr($bpp[$key]) . "";
// wBitCount; // Bits per pixel
$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
$icondata .= phpthumb_functions::LittleEndian2String($dwBytesInRes, 4);
// dwBytesInRes; // How many bytes in this resource?
$icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset, 4);
// dwImageOffset; // Where in the file is this image?
$dwImageOffset += strlen($BitmapInfoHeader[$key]);
$dwImageOffset += strlen($icXOR[$key]);
$dwImageOffset += strlen($icAND[$key]);
}
foreach ($gd_image_array as $key => $gd_image) {
$icondata .= $BitmapInfoHeader[$key];
$icondata .= $icXOR[$key];
//.........这里部分代码省略.........
示例4: isImageTrueColor
static function isImageTrueColor(&$imageObject, $mimeData)
{
return ImageIsTrueColor($imageObject);
}
示例5: Rotate
function Rotate()
{
if (!function_exists('ImageRotate')) {
return false;
}
if (!empty($this->ra) || !empty($this->ar)) {
$this->config_background_hexcolor = !empty($this->bg) ? $this->bg : $this->config_background_hexcolor;
if (!eregi('^[0-9A-F]{6}$', $this->config_background_hexcolor)) {
$this->ErrorImage('Invalid hex color string "' . $this->config_background_hexcolor . '" for parameter "bg"');
}
$rotate_angle = 0;
if (!empty($this->ra)) {
$rotate_angle = floatval($this->ra);
} else {
if ($this->ar == 'l' && $this->source_height > $this->source_width) {
$rotate_angle = 270;
} elseif ($this->ar == 'L' && $this->source_height > $this->source_width) {
$rotate_angle = 90;
} elseif ($this->ar == 'p' && $this->source_width > $this->source_height) {
$rotate_angle = 90;
} elseif ($this->ar == 'P' && $this->source_width > $this->source_height) {
$rotate_angle = 270;
}
}
while ($rotate_angle < 0) {
$rotate_angle += 360;
}
$rotate_angle = $rotate_angle % 360;
if ($rotate_angle != 0) {
if (ImageColorTransparent($this->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($this->gdimg_source)) {
// convert paletted image to true-color before rotating to prevent nasty aliasing artifacts
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
$gdimg_newsrc = $this->ImageCreateFunction($this->source_width, $this->source_height);
$background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor);
ImageFilledRectangle($gdimg_newsrc, 0, 0, $this->source_width, $this->source_height, phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor));
ImageCopy($gdimg_newsrc, $this->gdimg_source, 0, 0, 0, 0, $this->source_width, $this->source_height);
ImageDestroy($this->gdimg_source);
unset($this->gdimg_source);
$this->gdimg_source = $gdimg_newsrc;
unset($gdimg_newsrc);
} else {
ImageColorSet($this->gdimg_source, ImageColorTransparent($this->gdimg_source), hexdec(substr($this->config_background_hexcolor, 0, 2)), hexdec(substr($this->config_background_hexcolor, 2, 2)), hexdec(substr($this->config_background_hexcolor, 4, 2)));
ImageColorTransparent($this->gdimg_source, -1);
}
}
$background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_source, $this->config_background_hexcolor);
$this->gdimg_source = ImageRotate($this->gdimg_source, $rotate_angle, $background_color);
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
}
}
return true;
}
示例6: Rotate
//.........这里部分代码省略.........
$rotate_angle = 180;
break;
case 6:
$rotate_angle = 270;
break;
case 8:
$rotate_angle = 90;
break;
default:
$this->DebugMessage('EXIF auto-rotate failed because unknown $exif_data[Orientation] "' . @$exif_data['Orientation'] . '"', __FILE__, __LINE__);
return false;
break;
}
$this->DebugMessage('EXIF auto-rotate set to ' . $rotate_angle . ' degrees ($exif_data[Orientation] = "' . @$exif_data['Orientation'] . '")', __FILE__, __LINE__);
} else {
$this->DebugMessage('failed: exif_read_data(' . $this->sourceFilename . ')', __FILE__, __LINE__);
return false;
}
} else {
$this->DebugMessage('!function_exists(exif_read_data)', __FILE__, __LINE__);
return false;
}
} else {
$this->DebugMessage('Cannot auto-rotate from EXIF data because $this->sourceFilename is empty', __FILE__, __LINE__);
return false;
}
} else {
$this->DebugMessage('Cannot auto-rotate from EXIF data because PHP is less than v4.2.0 (' . phpversion() . ')', __FILE__, __LINE__);
return false;
}
} elseif ($this->ar == 'l' && $this->source_height > $this->source_width) {
$rotate_angle = 270;
} elseif ($this->ar == 'L' && $this->source_height > $this->source_width) {
$rotate_angle = 90;
} elseif ($this->ar == 'p' && $this->source_width > $this->source_height) {
$rotate_angle = 90;
} elseif ($this->ar == 'P' && $this->source_width > $this->source_height) {
$rotate_angle = 270;
}
}
while ($rotate_angle < 0) {
$rotate_angle += 360;
}
$rotate_angle = $rotate_angle % 360;
if ($rotate_angle != 0) {
$background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_source, $this->config_background_hexcolor);
if (phpthumb_functions::gd_version() >= 2 && $this->thumbnailFormat == 'png' && !$this->bg && $rotate_angle % 90) {
if ($gdimg_rotate_mask = phpthumb_functions::ImageCreateFunction(ImageSX($this->gdimg_source), ImageSY($this->gdimg_source))) {
$this->gdimg_source = ImageRotate($this->gdimg_source, $rotate_angle, $background_color);
$color_mask_opaque = ImageColorAllocate($gdimg_rotate_mask, 0xff, 0xff, 0xff);
$color_mask_transparent = ImageColorAllocate($gdimg_rotate_mask, 0x0, 0x0, 0x0);
ImageFilledRectangle($gdimg_rotate_mask, 0, 0, ImageSX($gdimg_rotate_mask), ImageSY($gdimg_rotate_mask), $color_mask_opaque);
$gdimg_rotate_mask = ImageRotate($gdimg_rotate_mask, $rotate_angle, $color_mask_transparent);
ImageAlphaBlending($this->gdimg_source, false);
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=')) {
ImageSaveAlpha($this->gdimg_source, true);
}
$this->is_alpha = true;
phpthumb_filters::ApplyMask($gdimg_rotate_mask, $this->gdimg_source);
ImageDestroy($gdimg_rotate_mask);
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
} else {
$this->DebugMessage('ImageCreateFromStringReplacement() failed for "' . $MaskFilename . '"', __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__);
} else {
$this->DebugMessage('Using non-alpha rotate because $this->thumbnailFormat is "' . $this->thumbnailFormat . '"', __FILE__, __LINE__);
}
if (ImageColorTransparent($this->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($this->gdimg_source)) {
// convert paletted image to true-color before rotating to prevent nasty aliasing artifacts
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
$gdimg_newsrc = phpthumb_functions::ImageCreateFunction($this->source_width, $this->source_height);
$background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor);
ImageFilledRectangle($gdimg_newsrc, 0, 0, $this->source_width, $this->source_height, phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $this->config_background_hexcolor));
ImageCopy($gdimg_newsrc, $this->gdimg_source, 0, 0, 0, 0, $this->source_width, $this->source_height);
ImageDestroy($this->gdimg_source);
unset($this->gdimg_source);
$this->gdimg_source = $gdimg_newsrc;
unset($gdimg_newsrc);
} else {
ImageColorSet($this->gdimg_source, ImageColorTransparent($this->gdimg_source), hexdec(substr($this->config_background_hexcolor, 0, 2)), hexdec(substr($this->config_background_hexcolor, 2, 2)), hexdec(substr($this->config_background_hexcolor, 4, 2)));
ImageColorTransparent($this->gdimg_source, -1);
}
}
$this->gdimg_source = ImageRotate($this->gdimg_source, $rotate_angle, $background_color);
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
}
}
}
return true;
}
示例7: image_preview
function image_preview($path_to_primary_image, $maximum_width)
{
//Globalize appropriate variables.
global $CONFIG, $lang_image_processor_php, $preview_image_directory;
//Determine thumbnail method.
$method = $CONFIG['thumb_method'];
if ($method == 'gd2' and !function_exists('imageistruecolor')) {
//Set ignore imageistruecolor to false.
$ignore = 0;
} else {
//Set $ignore image is true color to true.
$ignore = 1;
}
// Get image info.
$source_image_size_and_type = getimagesize($path_to_primary_image) or die($lang_image_processor_php['file_corrupt']);
$source_image_width = $source_image_size_and_type[0];
$source_image_height = $source_image_size_and_type[1];
$source_image_type = $source_image_size_and_type[2];
//We need specify the path for the transitory file.
// Create a prefix for easier human recognition.
$prefix = "pre_";
//Set the correct file extension.
if ($source_image_type == '1') {
$suffix = '.gif';
} elseif ($source_image_type == '2') {
$suffix = '.jpg';
} elseif ($source_image_type == '3') {
$suffix = '.png';
}
// Generate the unique name.
do {
$seed = substr(md5(microtime() . getmypid()), 0, 8);
$path_to_preview_image = $preview_image_directory . $prefix . $seed . $suffix;
} while (file_exists($path_to_preview_image));
//Now we can upload the file.
// Calculate dimensions.
if ($source_image_width > $maximum_width) {
$new_width = (int) $maximum_width;
$new_height = (int) ($source_image_height * ($maximum_width / $source_image_width));
} else {
$new_width = $source_image_width;
$new_height = $source_image_height;
}
//Begin processing if GD is used.
if ($method == "gd2" or $method == "gd1") {
// Get image handle
$image_handle = get_handle($path_to_primary_image);
// Create the destination image handle.
if ($method == "gd2") {
if ($ignore) {
if (ImageIsTrueColor($image_handle)) {
$destination_image_handle = ImageCreateTrueColor($new_width, $new_height);
} else {
$destination_image_handle = ImageCreate($new_width, $new_height);
}
} else {
$destination_image_handle = ImageCreate($new_width, $new_height);
}
} elseif ($method == "gd1") {
$destination_image_handle = ImageCreate($new_width, $new_height);
}
// Resize the image
if ($method == "gd2") {
//Use the higher quality function imagecopyresampled.
imagecopyresampled($destination_image_handle, $image_handle, 0, 0, 0, 0, $new_width, $new_height, $source_image_width, $source_image_height);
} elseif ($method == "gd1") {
//Use the lower quality imagecopyresized.
imagecopyresized($destination_image_handle, $image_handle, 0, 0, 0, 0, $new_width, $new_height, $source_image_width, $source_image_height);
}
//Destroy $image_handle
imagedestroy($image_handle);
// Write the image to disk.
if ($source_image_type == "2") {
imagejpeg($destination_image_handle, $path_to_preview_image) or die($lang_image_processor_php['no_write']);
} elseif ($source_image_type == "3") {
imagepng($destination_image_handle, $path_to_preview_image) or die($lang_image_processor_php['no_write']);
}
// Destroy $destination_image_handle.
imagedestroy($destination_image_handle);
} elseif ($method == "im") {
// Set IM path.
$im_path = $CONFIG['impath'];
//Check the IM path for the final slash.
if (eregi('/$', $im_path) or empty($im_path)) {
$trailing_slash = "";
} else {
$trailing_slash = "/";
}
//Determine real paths to files.
$real_path_to_primary_image = realpath($path_to_primary_image);
$real_path_to_preview_image = realpath($path_to_preview_image);
// Prevent the user from creating a process zombie by aborting while IM does its work.
ignore_user_abort(true);
// Issue the command for resizing to IM. Have ImageMagick write the image to disk.
$output = array();
$cmd = "{$CONFIG['impath']}" . $trailing_slash . "convert -geometry {$new_width}x{$new_height} \"{$real_path_to_primary_image}\" \"{$real_path_to_preview_image}\"";
exec($cmd, $output, $retval);
// Restore the user abort setting.
ignore_user_abort(false);
if ($retval) {
//.........这里部分代码省略.........
示例8: GDtoICOstr
function GDtoICOstr(&$gd_ico_array)
{
foreach ($gd_ico_array as $key => $gd_image) {
$IcoWidths[$key] = ImageSX($gd_image);
$IcoHeights[$key] = ImageSY($gd_image);
$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
$totalcolors[$key] = ImageColorsTotal($gd_image);
$icXOR[$key] = '';
for ($y = $IcoHeights[$key] - 1; $y >= 0; $y--) {
for ($x = 0; $x < $IcoWidths[$key]; $x++) {
$argb = $this->gpc($gd_image, $x, $y);
$a = round(255 * ((127 - $argb['alpha']) / 127));
$r = $argb['red'];
$g = $argb['green'];
$b = $argb['blue'];
if ($bpp[$key] == 32) {
$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
} elseif ($bpp[$key] == 24) {
$icXOR[$key] .= chr($b) . chr($g) . chr($r);
}
if ($a < 128) {
@($icANDmask[$key][$y] .= '1');
} else {
@($icANDmask[$key][$y] .= '0');
}
}
while (strlen($icANDmask[$key][$y]) % 32) {
$icANDmask[$key][$y] .= '0';
}
}
$icAND[$key] = '';
foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
}
}
}
foreach ($gd_ico_array as $key => $gd_image) {
$biSizeImage = $IcoWidths[$key] * $IcoHeights[$key] * ($bpp[$key] / 8);
$bfh[$key] = '';
$bfh[$key] .= "(";
$bfh[$key] .= $this->le2s($IcoWidths[$key], 4);
$bfh[$key] .= $this->le2s($IcoHeights[$key] * 2, 4);
$bfh[$key] .= "";
$bfh[$key] .= chr($bpp[$key]) . "";
$bfh[$key] .= "";
$bfh[$key] .= $this->le2s($biSizeImage, 4);
$bfh[$key] .= "";
$bfh[$key] .= "";
$bfh[$key] .= "";
$bfh[$key] .= "";
}
$icondata = "";
$icondata .= "";
$icondata .= $this->le2s(count($gd_ico_array), 2);
$dwImageOffset = 6 + count($gd_ico_array) * 16;
foreach ($gd_ico_array as $key => $gd_image) {
$icondata .= chr($IcoWidths[$key]);
$icondata .= chr($IcoHeights[$key]);
$icondata .= chr($totalcolors[$key]);
$icondata .= "";
$icondata .= "";
$icondata .= chr($bpp[$key]) . "";
$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
$icondata .= $this->le2s($dwBytesInRes, 4);
$icondata .= $this->le2s($dwImageOffset, 4);
$dwImageOffset += strlen($bfh[$key]);
$dwImageOffset += strlen($icXOR[$key]);
$dwImageOffset += strlen($icAND[$key]);
}
foreach ($gd_ico_array as $key => $gd_image) {
$icondata .= $bfh[$key];
$icondata .= $icXOR[$key];
$icondata .= $icAND[$key];
}
return $icondata;
}