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


PHP phpThumb::RenderOutput方法代码示例

本文整理汇总了PHP中phpThumb::RenderOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP phpThumb::RenderOutput方法的具体用法?PHP phpThumb::RenderOutput怎么用?PHP phpThumb::RenderOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpThumb的用法示例。


在下文中一共展示了phpThumb::RenderOutput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate_thumbnail

/**
 * Thumbnail generation
 */
function generate_thumbnail(&$file, &$width, &$height, $max_width, $max_height, $cache_tag)
{
    global $config;
    $thumb_cache_tag = $cache_tag . '_' . $max_width . 'x' . $max_height;
    // the names of the existing or to-be created thumbnail- still missing dimensions
    $thumb_name = './cache/' . CACHE_THUMBS . '/' . ($config['hierarchical'] ? substr($cache_tag, 0, 1) . '/' : '') . $cache_tag;
    // did we already create this thumbnail?
    if (THUMB_CACHE_TARGET && html_image_get_cache($thumb_cache_tag, $width, $height)) {
        // get updated filename
        $file = $thumb_name . '_' . $width . 'x' . $height . '.jpg';
        return;
    }
    // thumbnail not created yet
    $scale = min($max_width / $width, $max_height / $height);
    $width = round($width * $scale);
    $height = round($height * $scale);
    // really need to scale?
    $thumb_must_scale = $config['thumbnail_level'] == TUMB_SCALE || $config['thumbnail_level'] == TUMB_REDUCE_ONLY && $scale < 1 || $config['thumbnail_level'] > 1 && $config['thumbnail_level'] < @filesize($file);
    #dump("scaling required: ".(int)$thumb_must_scale." filesize: ".@filesize($file));
    // perform actual scaling
    if ($thumb_must_scale) {
        $phpThumb = new phpThumb();
        // use of truepath was added for php 5.4 apparently- otherwise thumbnail creation would inadvertantly fail
        $phpThumb->sourceFilename = truepath($file);
        $phpThumb->w = $max_width;
        $phpThumb->h = $max_height;
        if ($config['thumbnail_quality']) {
            $phpThumb->q = $config['thumbnail_quality'];
        }
        // set cache filename
        $thumb_name .= '_' . $width . 'x' . $height . '.jpg';
        #dump("thumbname:$thumb_name");
        // check to see if file already exists in cache, and output it with no processing if it does
        if (is_writable(dirname($thumb_name)) || is_writable($thumb_name)) {
            if (@filesize($thumb_name) || $phpThumb->GenerateThumbnail() && $phpThumb->RenderOutput() && file_put_contents($thumb_name, $phpThumb->outputImageData)) {
                $file = $thumb_name;
                if (THUMB_CACHE_TARGET) {
                    html_image_put_cache($thumb_cache_tag, $width . 'x' . $height);
                }
            }
            /*
            			# emergency debugging
            			else
            			{
            				dlog("Fail: $thumb_name");
            				dlog("fs: ".@filesize($thumb_name));
            				dlog($phpThumb->GenerateThumbnail());
            				dlog($phpThumb->RenderOutput());
            				dlog($phpThumb->debugmessages);
            			}
            */
        }
        // free memory
        $phpThumb = null;
    }
}
开发者ID:huya1010,项目名称:videodb,代码行数:59,代码来源:function.html_image.php

示例2: basename

 // or $phpThumb->setSourceImageResource($gd_image_resource);
 // set parameters (see "URL Parameters" in phpthumb.readme.txt)
 $phpThumb->setParameter('w', $thumbnail_width);
 //$phpThumb->setParameter('h', 100);
 //$phpThumb->setParameter('fltr', 'gam|1.2');
 // set options (see phpThumb.config.php)
 // here you must preface each option with "config_"
 $phpThumb->setParameter('config_output_format', 'jpeg');
 $phpThumb->setParameter('config_imagemagick_path', '/usr/local/bin/convert');
 //$phpThumb->setParameter('config_allow_src_above_docroot', true); // needed if you're working outside DOCUMENT_ROOT, in a temp dir for example
 // generate & output thumbnail
 $output_filename = './thumbnails/' . basename($_FILES['userfile']['name']) . '_' . $thumbnail_width . '.' . $phpThumb->config_output_format;
 if ($phpThumb->GenerateThumbnail()) {
     // this line is VERY important, do not remove it!
     if ($output_filename) {
         if ($capture_raw_data && $phpThumb->RenderOutput()) {
             // RenderOutput renders the thumbnail data to $phpThumb->outputImageData, not to a file or the browser
             mysql_query("INSERT INTO `table` (`thumbnail`) VALUES ('" . mysql_escape_string($phpThumb->outputImageData) . "') WHERE (`id` = '" . $id . "'");
         } elseif ($phpThumb->RenderToFile($output_filename)) {
             // do something on success
             echo 'Successfully rendered:<br><img src="' . $output_filename . '">';
         } else {
             // do something with debug/error messages
             echo 'Failed (size=' . $thumbnail_width . '):<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>';
         }
     } else {
         $phpThumb->OutputThumbnail();
     }
 } else {
     // do something with debug/error messages
     echo 'Failed (size=' . $thumbnail_width . ').<br>';
开发者ID:kinj1987,项目名称:evo-league,代码行数:31,代码来源:phpThumb.demo.object.php

示例3: generateThumb

function generateThumb($imgDir, $picName, $extension, $thumbtext)
{
    require_once '../thumb/phpthumb.class.php';
    require '../variables.php';
    $thumbNames = array();
    $imgUrl = $imgDir . $picName . "." . $extension;
    $thumbDir = "thumbnails/";
    // echo "<p>$imgUrl</p>";
    // create 3 sizes of thumbnail
    $thumbnail_widths = getThumbnailWidths();
    foreach ($thumbnail_widths as $thumbnail_width) {
        // Note: If you want to loop through and create multiple
        //   thumbnails from different image sources, you should
        //   create and dispose an instance of phpThumb() each time
        //   through the loop and not reuse the object.
        $phpThumb = new phpThumb();
        // set data
        $phpThumb->setSourceFilename($imgUrl);
        // or $phpThumb->setSourceData($binary_image_data);
        // or $phpThumb->setSourceImageResource($gd_image_resource);
        // $gd_img = imagecreatefrom($imgPath.$picturename);
        // $phpThumb->setSourceImageResource($gd_img);
        // set parameters (see "URL Parameters" in phpthumb.readme.txt)
        $phpThumb->setParameter('w', $thumbnail_width);
        //$phpThumb->setParameter('h', 100);
        $fParam = 'wmt|Click to open (^Xx^Y)|1|B|FFFFFF||100|0||000000|100|x';
        if (!empty($thumbtext)) {
            $fParamTop = 'wmt| ' . $thumbtext . ' |2|T|000000||100|0||CCCCCC|100|x';
            $phpThumb->setParameter('fltr', $fParamTop);
        }
        $phpThumb->setParameter('fltr', $fParam);
        $phpThumb->setParameter('fltr', 'bord|1');
        // set options (see phpThumb.config.php)
        // here you must preface each option with "config_"
        $phpThumb->setParameter('config_output_format', 'png');
        // $phpThumb->setParameter('config_imagemagick_path', '/usr/local/bin/convert');
        // $phpThumb->setParameter('config_imagemagick_path', '.');
        //$phpThumb->setParameter('config_allow_src_above_docroot', true); // needed if you're working outside DOCUMENT_ROOT, in a temp dir for example
        // generate & output thumbnail
        $output_filename = $imgDir . $thumbDir . $picName . '_' . $thumbnail_width . '.' . $phpThumb->config_output_format;
        if ($phpThumb->GenerateThumbnail()) {
            // this line is VERY important, do not remove it!
            if ($output_filename) {
                if ($capture_raw_data && $phpThumb->RenderOutput()) {
                    // RenderOutput renders the thumbnail data to $phpThumb->outputImageData, not to a file or the browser
                    // mysql_query("INSERT INTO `table` (`thumbnail`) VALUES ('".mysql_escape_string($phpThumb->outputImageData)."') WHERE (`id` = '".$id."'");
                } elseif ($phpThumb->RenderToFile($output_filename)) {
                    $thumbNames[] = array($thumbnail_width, $output_filename);
                } else {
                    // do something with debug/error messages
                    // echo 'Failed (size=' . $thumbnail_width . '):<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>';
                }
            } else {
                $phpThumb->OutputThumbnail();
            }
        } else {
            // do something with debug/error messages
            //echo '<p>Thumbnail generation failed (size='.$thumbnail_width.').</p>';
            //echo '<div style="background-color:#FFEEDD; font-weight: bold; padding: 10px;">'.$phpThumb->fatalerror.'</div>';
            //echo '<form><textarea rows="10" cols="60" wrap="off">'.htmlentities(implode("\n* ", $phpThumb->debugmessages)).'</textarea></form><hr>';
        }
        // remember to unset the object each time through the loop
        unset($phpThumb);
    }
    return $thumbNames;
}
开发者ID:kinj1987,项目名称:evo-league,代码行数:66,代码来源:functions.php


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