本文整理匯總了PHP中phpthumb_functions::gd_version方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpthumb_functions::gd_version方法的具體用法?PHP phpthumb_functions::gd_version怎麽用?PHP phpthumb_functions::gd_version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpthumb_functions
的用法示例。
在下文中一共展示了phpthumb_functions::gd_version方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: spit_phpthumb_image
function spit_phpthumb_image($filepath, $configarray = array())
{
// set up class
global $CFG, $PHPTHUMB_CONFIG;
$phpThumb = new phpThumb();
// import default config
if (!empty($PHPTHUMB_CONFIG)) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_' . $key;
$phpThumb->setParameter($keyname, $value);
}
}
// import passed params
if (!empty($configarray)) {
foreach ($configarray as $key => $value) {
$keyname = $key;
$phpThumb->setParameter($keyname, $value);
}
}
$phpThumb->setSourceFilename($filepath);
if (!is_file($phpThumb->sourceFilename) && !phpthumb_functions::gd_version()) {
if (!headers_sent()) {
// base64-encoded error image in GIF format
$ERROR_NOGD = 'R0lGODlhIAAgALMAAAAAABQUFCQkJDY2NkZGRldXV2ZmZnJycoaGhpSUlKWlpbe3t8XFxdXV1eTk5P7+/iwAAAAAIAAgAAAE/vDJSau9WILtTAACUinDNijZtAHfCojS4W5H+qxD8xibIDE9h0OwWaRWDIljJSkUJYsN4bihMB8th3IToAKs1VtYM75cyV8sZ8vygtOE5yMKmGbO4jRdICQCjHdlZzwzNW4qZSQmKDaNjhUMBX4BBAlmMywFSRWEmAI6b5gAlhNxokGhooAIK5o/pi9vEw4Lfj4OLTAUpj6IabMtCwlSFw0DCKBoFqwAB04AjI54PyZ+yY3TD0ss2YcVmN/gvpcu4TOyFivWqYJlbAHPpOntvxNAACcmGHjZzAZqzSzcq5fNjxFmAFw9iFRunD1epU6tsIPmFCAJnWYE0FURk7wJDA0MTKpEzoWAAskiAAA7';
header('Content-Type: image/gif');
echo base64_decode($ERROR_NOGD);
} else {
echo '*** ERROR: No PHP-GD support available ***';
}
exit;
}
$phpThumb->SetCacheFilename();
if (!file_exists($phpThumb->cache_filename) && is_writable(dirname($phpThumb->cache_filename))) {
// error_log("generating to cache: " . $phpThumb->cache_filename);
$phpThumb->CleanUpCacheDirectory();
$phpThumb->GenerateThumbnail();
$phpThumb->RenderToFile($phpThumb->cache_filename);
}
if (is_file($phpThumb->cache_filename)) {
// error_log("sending from cache: " . $phpThumb->cache_filename);
if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
$mimetype = phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]);
}
spitfile_with_mtime_check($phpThumb->cache_filename, $mimetype);
} else {
// error_log("phpthumb cache file doesn't exist: " . $phpThumb->cache_filename);
$phpThumb->GenerateThumbnail();
$phpThumb->OutputThumbnail();
exit;
}
}
示例2: die
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['phpthumb_version'] = $phpThumb->phpthumb_version;
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
unset($phpThumb);
?>
<html>
<head>
<title>Demo of phpThumb() - thumbnails created by PHP using GD and/or ImageMagick</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
</head>
<body bgcolor="#C5C5C5">
This is a demo of <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a> (current version: v<?php
echo @$ServerInfo['phpthumb_version'];
?>
)<br>
<a href="index.php?list=1">Other phpThumb() demos</a> are also available.<br>
示例3: 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;
}
示例4: ImageCreateFunction
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));
}
示例5: ImageResizeFunction
function ImageResizeFunction(&$dst_im, &$src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH)
{
$this->DebugMessage('ImageResizeFunction($o, $s, ' . $dstX . ', ' . $dstY . ', ' . $srcX . ', ' . $srcY . ', ' . $dstW . ', ' . $dstH . ', ' . $srcW . ', ' . $srcH . ')', __FILE__, __LINE__);
if ($dstW == $srcW && $dstH == $srcH) {
return ImageCopy($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH);
}
if (phpthumb_functions::gd_version() >= 2.0) {
if ($this->config_disable_imagecopyresampled) {
return phpthumb_functions::ImageCopyResampleBicubic($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH);
}
return ImageCopyResampled($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH);
}
return ImageCopyResized($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH);
}
示例6: MaxFileSize
function MaxFileSize()
{
if (phpthumb_functions::gd_version() < 2) {
return false;
}
if (!empty($this->maxb) && $this->maxb > 0) {
switch ($this->thumbnailFormat) {
case 'png':
case 'gif':
$imgRenderFunction = 'image' . $this->thumbnailFormat;
ob_start();
$imgRenderFunction($this->gdimg_output);
$imgdata = ob_get_contents();
ob_end_clean();
if (strlen($imgdata) > $this->maxb) {
for ($i = 8; $i >= 1; $i--) {
$tempIMG = ImageCreateTrueColor(ImageSX($this->gdimg_output), ImageSY($this->gdimg_output));
ImageCopy($tempIMG, $this->gdimg_output, 0, 0, 0, 0, ImageSX($this->gdimg_output), ImageSY($this->gdimg_output));
ImageTrueColorToPalette($tempIMG, true, pow(2, $i));
ob_start();
$imgRenderFunction($tempIMG);
$imgdata = ob_get_contents();
ob_end_clean();
if (strlen($imgdata) <= $this->maxb) {
ImageTrueColorToPalette($this->gdimg_output, true, pow(2, $i));
break;
}
}
}
if (strlen($imgdata) > $this->maxb) {
ImageTrueColorToPalette($this->gdimg_output, true, pow(2, $i));
return false;
}
break;
case 'jpeg':
ob_start();
ImageJPEG($this->gdimg_output);
$imgdata = ob_get_contents();
ob_end_clean();
$OriginalJPEGquality = $this->thumbnailQuality;
if (strlen($imgdata) > $this->maxb) {
for ($i = 3; $i < 20; $i++) {
$q = round(100 * (1 - log10($i / 2)));
ob_start();
ImageJPEG($this->gdimg_output, '', $q);
$imgdata = ob_get_contents();
ob_end_clean();
$this->thumbnailQuality = $q;
if (strlen($imgdata) <= $this->maxb) {
break;
}
}
}
if (strlen($imgdata) > $this->maxb) {
return false;
}
break;
default:
return false;
break;
}
}
return true;
}
示例7: Elipse
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);
phpthumb_filters::ApplyMask($gdimg_elipsemask, $gdimg);
ImageDestroy($gdimg_elipsemask);
return true;
} 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;
}
示例8: elseif
} elseif (in_array($key, $allowedGETparameters)) {
$phpThumb->DebugMessage('setParameter(' . $key . ', ' . $phpThumb->phpThumbDebugVarDump($value) . ')', __FILE__, __LINE__);
$phpThumb->setParameter($key, $value);
} else {
$phpThumb->ErrorImage('Forbidden parameter: ' . $key);
}
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[3]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '3') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
//if (!@$_GET['phpThumbDebug'] && !$phpThumb->sourceFilename && !function_exists('ImageJPEG') && !function_exists('ImagePNG') && !function_exists('ImageGIF')) {
if (!@$_GET['phpThumbDebug'] && !is_file($phpThumb->sourceFilename) && !phpthumb_functions::gd_version()) {
if (!headers_sent()) {
// base64-encoded error image in GIF format
$ERROR_NOGD = 'R0lGODlhIAAgALMAAAAAABQUFCQkJDY2NkZGRldXV2ZmZnJycoaGhpSUlKWlpbe3t8XFxdXV1eTk5P7+/iwAAAAAIAAgAAAE/vDJSau9WILtTAACUinDNijZtAHfCojS4W5H+qxD8xibIDE9h0OwWaRWDIljJSkUJYsN4bihMB8th3IToAKs1VtYM75cyV8sZ8vygtOE5yMKmGbO4jRdICQCjHdlZzwzNW4qZSQmKDaNjhUMBX4BBAlmMywFSRWEmAI6b5gAlhNxokGhooAIK5o/pi9vEw4Lfj4OLTAUpj6IabMtCwlSFw0DCKBoFqwAB04AjI54PyZ+yY3TD0ss2YcVmN/gvpcu4TOyFivWqYJlbAHPpOntvxNAACcmGHjZzAZqzSzcq5fNjxFmAFw9iFRunD1epU6tsIPmFCAJnWYE0FURk7wJDA0MTKpEzoWAAskiAAA7';
header('Content-Type: image/gif');
echo base64_decode($ERROR_NOGD);
} else {
echo '*** ERROR: No PHP-GD support available ***';
}
exit;
}
// check to see if file can be output from source with no processing or caching
$CanPassThroughDirectly = true;
if ($phpThumb->rawImageData) {
// data from SQL, should be fine
} elseif (eregi('^(f|ht)tp\\://', $phpThumb->src)) {
示例9: SourceImageToGD
//.........這裏部分代碼省略.........
$this->DebugMessage('ImageMagickThumbnailToGD() succeeded', __FILE__, __LINE__);
} else {
$this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__);
$imageHeader = '';
$gd_info = phpthumb_functions::gd_info();
$GDreadSupport = false;
switch (substr($this->rawImageData, 0, 3)) {
case 'GIF':
$imageHeader = 'Content-Type: image/gif';
$GDreadSupport = (bool) @$gd_info['GIF Read Support'];
break;
case "ÿØÿ":
$imageHeader = 'Content-Type: image/jpeg';
$GDreadSupport = (bool) @$gd_info['JPG Support'];
break;
case "‰" . 'PN':
$imageHeader = 'Content-Type: image/png';
$GDreadSupport = (bool) @$gd_info['PNG Support'];
break;
}
if ($imageHeader) {
// cannot create image for whatever reason (maybe ImageCreateFromJPEG et al are not available?)
// and ImageMagick is not available either, no choice but to output original (not resized/modified) data and exit
if ($this->config_error_die_on_source_failure && !$this->phpThumbDebug) {
$this->ErrorImage('All attempts to create GD image source failed (' . ($GDreadSupport ? 'source image probably corrupt' : 'GD does not have read support for "' . $imageHeader . '"') . '), cannot generate thumbnail');
} else {
//$this->DebugMessage('All attempts to create GD image source failed ('.($GDreadSupport ? 'source image probably corrupt' : 'GD does not have read support for "'.$imageHeader.'"').'), outputing raw image', __FILE__, __LINE__);
//if (!$this->phpThumbDebug) {
// header($imageHeader);
// echo $this->rawImageData;
// exit;
//}
return false;
}
}
switch (substr($this->rawImageData, 0, 2)) {
case 'BM':
ob_start();
if (!@(include_once dirname(__FILE__) . '/phpthumb.bmp.php')) {
ob_end_clean();
if ($this->phpThumbDebug) {
$this->DebugMessage('include_once(' . dirname(__FILE__) . '/phpthumb.bmp.php) failed', __FILE__, __LINE__);
return false;
}
return $this->ErrorImage('include_once(' . dirname(__FILE__) . '/phpthumb.bmp.php) failed');
}
ob_end_clean();
$phpthumb_bmp = new phpthumb_bmp();
if ($this->gdimg_source = $phpthumb_bmp->phpthumb_bmp2gd($this->rawImageData, phpthumb_functions::gd_version() >= 2.0)) {
$this->DebugMessage('$phpthumb_bmp->phpthumb_bmp2gd() succeeded', __FILE__, __LINE__);
break;
} elseif ($this->phpThumbDebug) {
$this->DebugMessage('phpthumb_bmp2db failed', __FILE__, __LINE__);
return false;
}
return $this->ErrorImage('ImageMagick is unavailable and phpThumb() does not support BMP source images without it');
break;
}
switch (substr($this->rawImageData, 0, 4)) {
case 'II' . "*":
case 'MM' . "*":
if ($this->phpThumbDebug) {
$this->DebugMessage('ImageMagick is unavailable and phpThumb() does not support TIFF source images without it', __FILE__, __LINE__);
return false;
}
return $this->ErrorImage('ImageMagick is unavailable and phpThumb() does not support TIFF source images without it');
break;
case "×ÍÆš":
if ($this->phpThumbDebug) {
$this->DebugMessage('ImageMagick is unavailable and phpThumb() does not support WMF source images without it', __FILE__, __LINE__);
return false;
}
return $this->ErrorImage('ImageMagick is unavailable and phpThumb() does not support WMF source images without it');
break;
}
if (!$this->gdimg_source) {
if ($this->phpThumbDebug) {
$this->DebugMessage('Unknown image type identified by "' . substr($this->rawImageData, 0, 4) . '" (' . phpthumb_functions::HexCharDisplay(substr($this->rawImageData, 0, 4)) . ') in SourceImageToGD()', __FILE__, __LINE__);
return false;
}
return $this->ErrorImage('Unknown image type identified by "' . substr($this->rawImageData, 0, 4) . '" (' . phpthumb_functions::HexCharDisplay(substr($this->rawImageData, 0, 4)) . ') in SourceImageToGD()');
}
}
}
}
if (!$this->gdimg_source) {
if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false)) {
$this->DebugMessage('All other attempts failed, but successfully using EXIF thumbnail as source image', __FILE__, __LINE__);
$this->gdimg_source = $gdimg_exif_temp;
// override allow-enlarging setting if EXIF thumbnail is the only source available
// otherwise thumbnails larger than the EXIF thumbnail will be created at EXIF size
$this->aoe = true;
return true;
}
return false;
}
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
return true;
}
示例10: gd_missing
function gd_missing()
{
require_once PLOGGER_DIR . '/plog-includes/lib/phpthumb/phpthumb.functions.php';
// This is copied over from phpthumb
return phpthumb_functions::gd_version() < 1;
}
示例11: die
<?php
$GDversion['string'] = 'unknown';
$GDversion['numeric'] = 0;
if (!@(include_once 'phpthumb.functions.php')) {
die('failed to open "phpthumb.functions.php"');
}
if (include_once 'phpthumb.class.php') {
$phpThumb = new phpThumb();
$phpthumb_version = $phpThumb->phpthumb_version;
unset($phpThumb);
$GDversion['string'] = phpthumb_functions::gd_version(true);
$GDversion['numeric'] = phpthumb_functions::gd_version(false);
} else {
die('failed to open "phpthumb.class.php"');
}
?>
<html>
<head>
<title>Demo of phpThumb() - thumbnails created by PHP</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
</head>
<body bgcolor="#C5C5C5">
This is a demo of <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a> (current version: v<?php
echo @$phpthumb_version;
?>
)<br>
A dynamic demo where you can set <strike>all</strike> some of the parmeters and see their effect is <a href="phpThumb.demo.demo2.php">here</a>.<br>
<br>
示例12: SourceImageToGD
//.........這裏部分代碼省略.........
// IFF
case 16:
// XBM
$this->DebugMessage('No built-in image creation function for image type "' . @$this->getimagesizeinfo[2] . '" ($this->getimagesizeinfo[2])', __FILE__, __LINE__);
break;
case '':
// no source file, source image was probably set by setSourceData()
break;
default:
$this->DebugMessage('Unknown value for $this->getimagesizeinfo[2]: "' . @$this->getimagesizeinfo[2] . '"', __FILE__, __LINE__);
break;
}
if (empty($this->gdimg_source)) {
// cannot create from filename, attempt to create source image with ImageCreateFromString, if possible
if ($ImageCreateWasAttempted) {
$this->DebugMessage(@$ImageCreateFromFunctionName . '() was attempted but FAILED', __FILE__, __LINE__);
}
if (empty($this->rawImageData)) {
$this->DebugMessage('Populating $this->rawImageData and attempting ImageCreateFromStringReplacement()', __FILE__, __LINE__);
if ($fp = @fopen($this->sourceFilename, 'rb')) {
$this->rawImageData = '';
$filesize = filesize($this->sourceFilename);
$blocksize = 16384;
$blockreads = ceil($filesize / $blocksize);
for ($i = 0; $i < $blockreads; $i++) {
$this->rawImageData .= fread($fp, $blocksize);
}
fclose($fp);
} else {
return $this->ErrorImage('cannot fopen("' . $this->sourceFilename . '") on line ' . __LINE__ . ' of ' . __FILE__);
}
}
$this->gdimg_source = $this->ImageCreateFromStringReplacement($this->rawImageData, true);
}
if (empty($this->gdimg_source)) {
$this->DebugMessage('$this->gdimg_source is still empty', __FILE__, __LINE__);
if ($this->ImageMagickThumbnailToGD()) {
// excellent, we have a thumbnailed source image
$this->DebugMessage('ImageMagickThumbnailToGD() succeeded', __FILE__, __LINE__);
} else {
$this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__);
$imageHeader = '';
switch (substr($this->rawImageData, 0, 3)) {
case 'GIF':
$imageHeader = 'Content-type: image/gif';
break;
case "ÿØÿ":
$imageHeader = 'Content-type: image/jpeg';
break;
case "‰" . 'PN':
$imageHeader = 'Content-type: image/png';
break;
}
if ($imageHeader) {
// cannot create image for whatever reason (maybe ImageCreateFromJPEG et al are not available?)
// and ImageMagick is not available either, no choice but to output original (not resized/modified) data and exit
if ($this->config_error_die_on_source_failure) {
$this->ErrorImage('All attempts to create GD image source failed (source image probably corrupt), cannot generate thumbnail');
} else {
$this->DebugMessage('All attempts to create GD image source failed, outputing raw image', __FILE__, __LINE__);
header($imageHeader);
echo $this->rawImageData;
exit;
}
}
switch (substr($this->rawImageData, 0, 2)) {
case 'BM':
if (@(include_once 'phpthumb.bmp.php')) {
$phpthumb_bmp = new phpthumb_bmp();
if ($this->gdimg_source = $phpthumb_bmp->phpthumb_bmp2gd($this->rawImageData, phpthumb_functions::gd_version() >= 2.0)) {
$this->DebugMessage('$phpthumb_bmp->phpthumb_bmp2gd() succeeded', __FILE__, __LINE__);
break;
} else {
return $this->ErrorImage('phpthumb_bmp2db failed');
}
} else {
return $this->ErrorImage('include_once(phpthumb.bmp.php) failed');
}
return $this->ErrorImage('ImageMagick is unavailable and phpThumb() does not support BMP source images without it');
break;
}
switch (substr($this->rawImageData, 0, 4)) {
case 'II' . "*":
case 'MM' . "*":
return $this->ErrorImage('ImageMagick is unavailable and phpThumb() does not support TIFF source images without it');
break;
case "×ÍÆš":
return $this->ErrorImage('ImageMagick is unavailable and phpThumb() does not support WMF source images without it');
break;
}
if (empty($this->gdimg_source)) {
return $this->ErrorImage('Unknown image type identified by "' . substr($this->rawImageData, 0, 4) . '" (' . phpthumb_functions::HexCharDisplay(substr($this->rawImageData, 0, 4)) . ') in SourceImageToGD()');
}
}
}
}
$this->source_width = ImageSX($this->gdimg_source);
$this->source_height = ImageSY($this->gdimg_source);
return true;
}
示例13: gd_missing
function gd_missing()
{
require_once dirname(__FILE__) . '/../../lib/phpthumb/phpthumb.functions.php';
// this is copied over from phpthumb
return phpthumb_functions::gd_version() < 1;
}