本文整理匯總了PHP中phpthumb_functions::HexCharDisplay方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpthumb_functions::HexCharDisplay方法的具體用法?PHP phpthumb_functions::HexCharDisplay怎麽用?PHP phpthumb_functions::HexCharDisplay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpthumb_functions
的用法示例。
在下文中一共展示了phpthumb_functions::HexCharDisplay方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ImageCreateFromStringReplacement
function ImageCreateFromStringReplacement(&$RawImageData, $DieOnErrors = false)
{
// there are serious bugs in the non-bundled versions of GD which may cause
// PHP to segfault when calling ImageCreateFromString() - avoid if at all possible
// when not using a bundled version of GD2
if (!phpthumb_functions::gd_version()) {
if ($DieOnErrors) {
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;
} else {
$this->DebugMessage('ImageCreateFromStringReplacement() failed: gd_version says "' . phpthumb_functions::gd_version() . '"', __FILE__, __LINE__);
return false;
}
}
if (phpthumb_functions::gd_is_bundled()) {
$this->DebugMessage('ImageCreateFromStringReplacement() calling built-in ImageCreateFromString()', __FILE__, __LINE__);
return @ImageCreateFromString($RawImageData);
}
if ($this->issafemode) {
$this->DebugMessage('ImageCreateFromStringReplacement() failed: cannot create temp file in SAFE_MODE', __FILE__, __LINE__);
return false;
}
switch (substr($RawImageData, 0, 3)) {
case 'GIF':
$ICFSreplacementFunctionName = 'ImageCreateFromGIF';
break;
case "ÿØÿ":
$ICFSreplacementFunctionName = 'ImageCreateFromJPEG';
break;
case "‰" . 'PN':
$ICFSreplacementFunctionName = 'ImageCreateFromPNG';
break;
default:
$this->DebugMessage('ImageCreateFromStringReplacement() failed: unknown fileformat signature "' . phpthumb_functions::HexCharDisplay(substr($RawImageData, 0, 3)) . '"', __FILE__, __LINE__);
return false;
break;
}
if ($tempnam = $this->phpThumb_tempnam()) {
if ($fp_tempnam = @fopen($tempnam, 'wb')) {
fwrite($fp_tempnam, $RawImageData);
fclose($fp_tempnam);
if ($ICFSreplacementFunctionName == 'ImageCreateFromGIF' && !function_exists($ICFSreplacementFunctionName)) {
// Need to create from GIF file, but ImageCreateFromGIF does not exist
ob_start();
if (!@(include_once dirname(__FILE__) . '/phpthumb.gif.php')) {
$ErrorMessage = 'Failed to include required file "' . dirname(__FILE__) . '/phpthumb.gif.php" in ' . __FILE__ . ' on line ' . __LINE__;
$this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
}
ob_end_clean();
// gif_loadFileToGDimageResource() cannot read from raw data, write to file first
if ($tempfilename = $this->phpThumb_tempnam()) {
if ($fp_tempfile = @fopen($tempfilename, 'wb')) {
fwrite($fp_tempfile, $RawImageData);
fclose($fp_tempfile);
$gdimg_source = gif_loadFileToGDimageResource($tempfilename);
$this->DebugMessage('gif_loadFileToGDimageResource(' . $tempfilename . ') completed', __FILE__, __LINE__);
$this->DebugMessage('deleting "' . $tempfilename . '"', __FILE__, __LINE__);
unlink($tempfilename);
return $gdimg_source;
// break;
} else {
$ErrorMessage = 'Failed to open tempfile in ' . __FILE__ . ' on line ' . __LINE__;
$this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
}
} else {
$ErrorMessage = 'Failed to open generate tempfile name in ' . __FILE__ . ' on line ' . __LINE__;
$this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
}
} elseif (function_exists($ICFSreplacementFunctionName) && ($gdimg_source = @$ICFSreplacementFunctionName($tempnam))) {
// great
$this->DebugMessage($ICFSreplacementFunctionName . '(' . $tempnam . ') succeeded', __FILE__, __LINE__);
$this->DebugMessage('deleting "' . $tempnam . '"', __FILE__, __LINE__);
unlink($tempnam);
return $gdimg_source;
} else {
// GD functions not available, or failed to create image
$this->DebugMessage($ICFSreplacementFunctionName . '(' . $tempnam . ') ' . (function_exists($ICFSreplacementFunctionName) ? 'failed' : 'does not exist'), __FILE__, __LINE__);
if (isset($_GET['phpThumbDebug'])) {
$this->phpThumbDebug();
}
}
} else {
$ErrorMessage = 'Failed to fopen(' . $tempnam . ', "wb") in ' . __FILE__ . ' on line ' . __LINE__ . "\n" . 'You may need to set $PHPTHUMB_CONFIG[temp_directory] in phpThumb.config.php';
if ($this->issafemode) {
$ErrorMessage = 'ImageCreateFromStringReplacement() failed in ' . __FILE__ . ' on line ' . __LINE__ . ': cannot create temp file in SAFE_MODE';
}
$this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
}
$this->DebugMessage('deleting "' . $tempnam . '"', __FILE__, __LINE__);
@unlink($tempnam);
} else {
$ErrorMessage = 'Failed to generate phpThumb_tempnam() in ' . __FILE__ . ' on line ' . __LINE__ . "\n" . 'You may need to set $PHPTHUMB_CONFIG[temp_directory] in phpThumb.config.php';
if ($this->issafemode) {
//.........這裏部分代碼省略.........
示例2: 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;
}
示例3: ImageCreateFromStringReplacement
function ImageCreateFromStringReplacement(&$RawImageData, $DieOnErrors = false)
{
// there are serious bugs in the non-bundled versions of GD which may cause
// PHP to segfault when calling ImageCreateFromString() - avoid if at all possible
// when not using a bundled version of GD2
$gd_info = phpthumb_functions::gd_info();
if (strpos($gd_info['GD Version'], 'bundled') !== false) {
return @ImageCreateFromString($RawImageData);
}
switch (substr($RawImageData, 0, 3)) {
case 'GIF':
$ICFSreplacementFunctionName = 'ImageCreateFromGIF';
break;
case "ÿØÿ":
$ICFSreplacementFunctionName = 'ImageCreateFromJPEG';
break;
case "‰" . 'PN':
$ICFSreplacementFunctionName = 'ImageCreateFromPNG';
break;
default:
$this->ErrorImage('Unknown image type identified by "' . substr($this->rawImageData, 0, 3) . '" (' . phpthumb_functions::HexCharDisplay(substr($this->rawImageData, 0, 3)) . ') in ImageCreateFromStringReplacement()');
break;
}
if ($tempnam = tempnam($this->config_temp_directory, 'pThumb')) {
if ($fp_tempnam = @fopen($tempnam, 'wb')) {
fwrite($fp_tempnam, $RawImageData);
fclose($fp_tempnam);
if ($ICFSreplacementFunctionName == 'ImageCreateFromGIF' && !function_exists($ICFSreplacementFunctionName)) {
// Need to create from GIF file, but ImageCreateFromGIF does not exist
if (@(include_once 'phpthumb.gif.php')) {
// gif_loadFileToGDimageResource() cannot read from raw data, write to file first
if ($tempfilename = tempnam($this->config_temp_directory, 'pThumb')) {
if ($fp_tempfile = @fopen($tempfilename, 'wb')) {
fwrite($fp_tempfile, $RawImageData);
fclose($fp_tempfile);
$gdimg_source = gif_loadFileToGDimageResource($tempfilename);
unlink($tempfilename);
return $gdimg_source;
break;
} else {
$ErrorMessage = 'Failed to open tempfile in ' . __FILE__ . ' on line ' . __LINE__;
}
} else {
$ErrorMessage = 'Failed to open generate tempfile name in ' . __FILE__ . ' on line ' . __LINE__;
}
} else {
$ErrorMessage = 'Failed to include required file "phpthumb.gif.php" in ' . __FILE__ . ' on line ' . __LINE__;
}
} elseif (function_exists($ICFSreplacementFunctionName) && ($gdimg_source = $ICFSreplacementFunctionName($tempnam))) {
// great
unlink($tempnam);
return $gdimg_source;
} else {
// GD functions not available
// 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);
exit;
}
} else {
$ErrorMessage = 'Failed to fopen(' . $tempnam . ', "wb") in ' . __FILE__ . ' on line ' . __LINE__ . "\n" . 'You may need to set $PHPTHUMB_CONFIG[temp_directory] in phpthumb.config.php';
}
unlink($tempnam);
} else {
$ErrorMessage = 'Failed to generate tempnam() in ' . __FILE__ . ' on line ' . __LINE__ . "\n" . 'You may need to set $PHPTHUMB_CONFIG[temp_directory] in phpthumb.config.php';
}
if ($DieOnErrors && !empty($ErrorMessage)) {
die($ErrorMessage);
}
return false;
}
示例4: 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;
}