当前位置: 首页>>代码示例>>PHP>>正文


PHP gif_loadFileToGDimageResource函数代码示例

本文整理汇总了PHP中gif_loadFileToGDimageResource函数的典型用法代码示例。如果您正苦于以下问题:PHP gif_loadFileToGDimageResource函数的具体用法?PHP gif_loadFileToGDimageResource怎么用?PHP gif_loadFileToGDimageResource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gif_loadFileToGDimageResource函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
     $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;
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:72,代码来源:phpthumb.class.php

示例2: 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) {
//.........这里部分代码省略.........
开发者ID:notzen,项目名称:exponent-cms,代码行数:101,代码来源:phpthumb.class.php

示例3: message_die

    @fclose($fptr);
    @chmod($filetmp, 0777);
}
$ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var';
if (@$ini_val('open_basedir') != '') {
    if (@phpversion() < '4.0.3') {
        message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file<br /><br />Please contact your server admin', '', __LINE__, __FILE__);
    }
    $move_file = 'move_uploaded_file';
} else {
    $move_file = 'copy';
}
// if it is a gif or a png to convert
if ($pic_subtype == 'gif') {
    include_once $phpbb_root_path . 'auction/graphic_files/phpthumb.gif.php';
    $src = gif_loadFileToGDimageResource($filetmp);
    @imagejpeg($src, $phpbb_root_path . AUCTION_PICTURE_UPLOAD_PATH . $pic_filename, 80);
    @unlink($filetmp);
    Imagedestroy($src);
} else {
    if ($pic_subtype == 'png') {
        $move_file($filetmp, $phpbb_root_path . AUCTION_PICTURE_UPLOAD_PATH . $pic_filename);
        @chmod($phpbb_root_path . AUCTION_PICTURE_UPLOAD_PATH . $pic_filename, 0777);
        $read_function = 'imagecreatefrompng';
        $src = @$read_function($phpbb_root_path . AUCTION_PICTURE_UPLOAD_PATH . $pic_filename);
        @unlink($phpbb_root_path . AUCTION_PICTURE_UPLOAD_PATH . $pic_filename);
        @imagejpeg($src, $phpbb_root_path . AUCTION_PICTURE_UPLOAD_PATH . $pic_filename, 80);
        Imagedestroy($src);
    } else {
        $move_file($filetmp, $phpbb_root_path . AUCTION_PICTURE_UPLOAD_PATH . $pic_filename);
        @unlink($filetmp);
开发者ID:wrtcoder,项目名称:mini_isp,代码行数:31,代码来源:auction_pic_upload.php


注:本文中的gif_loadFileToGDimageResource函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。