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


PHP phpThumb类代码示例

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


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

示例1: generateThumbnail

 private function generateThumbnail($destination, $filename, $size)
 {
     $thumbDestination = $destination . $size . DS;
     if (!is_dir($thumbDestination)) {
         mkdir($thumbDestination, 0777, true);
     }
     $imageSettings = $this->getConfig();
     if (sizeof($imageSettings) == 0) {
         return false;
     }
     $thumb = new phpThumb();
     foreach ($imageSettings[$size] as $key => $value) {
         $thumb->setParameter($key, $value);
     }
     $thumb->setSourceData(file_get_contents($destination . $filename));
     if ($thumb->GenerateThumbnail()) {
         // this line is VERY important, do not remove it!
         if ($thumb->RenderToFile($thumbDestination . $filename)) {
             return true;
         } else {
             throw new Exception("Nie udało mi się wygenerować miniaturki o rozmiarze - {$size} Ponieważ:\n {$thumb->debugmessages}");
         }
     } else {
         throw new Exception("Błąd generatora\n {$thumb->debugmessages}");
     }
     return false;
 }
开发者ID:jager,项目名称:cms,代码行数:27,代码来源:HandlerJpeg.php

示例2: 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;
    }
}
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:51,代码来源:iconslib.php

示例3: thumb

 function thumb()
 {
     if (empty($_GET['src'])) {
         die("No source image");
     }
     //width
     $width = !isset($_GET['w']) ? 100 : $_GET['w'];
     //height
     $height = !isset($_GET['h']) ? 150 : $_GET['h'];
     //quality
     $quality = !isset($_GET['q']) ? 75 : $_GET['q'];
     $sourceFilename = WWW_ROOT . IMAGES_URL . $_GET['src'];
     if (is_readable($sourceFilename)) {
         App::import('Vendor', 'Phpthumb', array('file' => 'phpthumb' . DS . 'phpthumb.class.php'));
         $phpThumb = new phpThumb();
         $phpThumb->src = $sourceFilename;
         $phpThumb->w = $width;
         $phpThumb->h = $height;
         $phpThumb->q = $quality;
         $phpThumb->config_imagemagick_path = '/usr/bin/convert';
         $phpThumb->config_prefer_imagemagick = false;
         $phpThumb->config_output_format = 'png';
         $phpThumb->config_error_die_on_error = true;
         $phpThumb->config_document_root = '';
         $phpThumb->config_temp_directory = APP . 'tmp';
         $phpThumb->config_cache_directory = CACHE . 'thumbs' . DS;
         $phpThumb->config_cache_disable_warning = true;
         $cacheFilename = md5($_SERVER['REQUEST_URI']);
         $phpThumb->cache_filename = $phpThumb->config_cache_directory . $cacheFilename;
         // Check if image is already cached.
         if (!is_file($phpThumb->cache_filename)) {
             if ($phpThumb->GenerateThumbnail()) {
                 $phpThumb->RenderToFile($phpThumb->cache_filename);
             } else {
                 die('Failed: ' . $phpThumb->error);
             }
         }
         if (is_file($phpThumb->cache_filename)) {
             // If thumb was already generated we want to use cached version
             $cachedImage = getimagesize($phpThumb->cache_filename);
             header('Content-Type: ' . $cachedImage['mime']);
             readfile($phpThumb->cache_filename);
             exit;
         }
     } else {
         // Can't read source
         die("Couldn't read source image " . $sourceFilename);
     }
 }
开发者ID:risnandar,项目名称:testing,代码行数:49,代码来源:images_controller.php

示例4: thumbnail

 public static function thumbnail($image_path, $thumb_path, $image_name, $thumbnail_width = 0, $thumbnail_height = 0)
 {
     require_once JPATH_ROOT . '/jelibs/phpthumb/phpthumb.class.php';
     // create phpThumb object
     $phpThumb = new phpThumb();
     // this is very important when using a single object to process multiple images
     $phpThumb->resetObject();
     // set data source
     $phpThumb->setSourceFilename($image_path . DS . $image_name);
     // set parameters (see "URL Parameters" in phpthumb.readme.txt)
     if ($thumbnail_width) {
         $phpThumb->setParameter('w', $thumbnail_width);
     }
     if ($thumbnail_height) {
         $phpThumb->setParameter('h', $thumbnail_height);
     }
     $phpThumb->setParameter('zc', 'l');
     // set parameters
     $phpThumb->setParameter('config_output_format', 'jpeg');
     // generate & output thumbnail
     $output_filename = str_replace('/', DS, $thumb_path) . DS . 't-' . $thumbnail_width . 'x' . $thumbnail_height . '-' . $image_name;
     # .'_'.$thumbnail_width.'.'.$phpThumb->config_output_format;
     $capture_raw_data = false;
     if ($phpThumb->GenerateThumbnail()) {
         //			$output_size_x = ImageSX($phpThumb->gdimg_output);
         //			$output_size_y = ImageSY($phpThumb->gdimg_output);
         //			if ($output_filename || $capture_raw_data) {
         ////				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>';
         ////				}
         //				$phpThumb->purgeTempFiles();
         //			} else {
         $phpThumb->RenderToFile($output_filename);
         //			}
     } else {
         // do something with debug/error messages
         //			echo 'Failed (size='.$thumbnail_width.').<br>';
         //			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>';
     }
     return $output_filename;
 }
开发者ID:ngxuanmui,项目名称:hp3,代码行数:49,代码来源:util.class.php

示例5: image_resize

function image_resize($image, $width, $height, $quality, $input_directory, $output_directory)
{
    $cache_dir = 'cache/';
    if ($input_directory !== '') {
        $source = $input_directory . $image;
    } else {
        $source = $image;
    }
    if ($output_directory !== '') {
        $target = $output_directory . $image;
    } else {
        $target = $image;
    }
    include_once DIR_FS_CATALOG . 'ext/phpthumb/phpthumb.class.php';
    // create phpThumb object
    $phpThumb = new phpThumb();
    // set data source -- do this first, any settings must be made AFTER this call
    $phpThumb->setSourceFilename($source);
    // set parameters (see "URL Parameters" in phpthumb.readme.txt)
    $phpThumb->setParameter('config_cache_directory', $cache_dir);
    if ($width !== '') {
        $phpThumb->setParameter('w', $width);
    } else {
        $phpThumb->setParameter('h', $height);
    }
    if ($quality !== '') {
        $phpThumb->setParameter('q', $quality);
    }
    // generate & output thumbnail
    if ($phpThumb->GenerateThumbnail()) {
        // this line is VERY important, do not remove it!
        if ($phpThumb->RenderToFile($target)) {
            // do something on success
            //		        echo 'Successfully rendered to "'.$image.'"';
        } else {
            // do something with debug/error messages
            echo 'Failed:<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>';
        }
    } else {
        // do something with debug/error messages
        echo 'Failed:<pre>' . $phpThumb->fatalerror . "\n\n" . implode("\n\n", $phpThumb->debugmessages) . '</pre>';
    }
    // return $output;
}
开发者ID:digideskio,项目名称:oscmax2,代码行数:44,代码来源:image_resize.php

示例6: uploadImages

 static function uploadImages($field, $item, $delImage = 0, $itemType = 'albums', $width = 0, $height = 0)
 {
     $jFileInput = new JInput($_FILES);
     $file = $jFileInput->get('jform', array(), 'array');
     // If there is no uploaded file, we have a problem...
     if (!is_array($file)) {
         //			JError::raiseWarning('', 'No file was selected.');
         return '';
     }
     // Build the paths for our file to move to the components 'upload' directory
     $fileName = $file['name'][$field];
     $tmp_src = $file['tmp_name'][$field];
     $image = '';
     $oldImage = '';
     $flagDelete = false;
     //		$item = $this->getItem();
     // if delete old image checked or upload new file
     if ($delImage || $fileName) {
         $oldImage = JPATH_ROOT . DS . str_replace('/', DS, $item->images);
         // unlink file
         if (is_file($oldImage)) {
             @unlink($oldImage);
         }
         $flagDelete = true;
         $image = '';
     }
     $date = date('Y') . DS . date('m') . DS . date('d');
     $dest = JPATH_ROOT . DS . 'images' . DS . $itemType . DS . $date . DS . $item->id . DS;
     // Make directory
     @mkdir($dest, 0777, true);
     if (isset($fileName) && $fileName) {
         $filepath = JPath::clean($dest . $fileName);
         /*
         if (JFile::exists($filepath)) {
         	JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_FILE_EXISTS'));	// File exists
         }
         */
         // Move uploaded file
         jimport('joomla.filesystem.file');
         if (!JFile::upload($tmp_src, $filepath)) {
             JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_UNABLE_TO_UPLOAD_FILE'));
             // Error in upload
             return '';
         }
         // if upload success, resize image
         if ($width) {
             require_once JPATH_ROOT . DS . 'jelibs/phpthumb/phpthumb.class.php';
             // create phpThumb object
             $phpThumb = new phpThumb();
             if (include_once JPATH_ROOT . DS . 'jelibs/phpthumb/phpThumb.config.php') {
                 foreach ($PHPTHUMB_CONFIG as $key => $value) {
                     $keyname = 'config_' . $key;
                     $phpThumb->setParameter($keyname, $value);
                 }
             }
             // this is very important when using a single object to process multiple images
             $phpThumb->resetObject();
             $phpThumb->setSourceFilename($filepath);
             // set parameters (see "URL Parameters" in phpthumb.readme.txt)
             $phpThumb->setParameter('w', $width);
             if ($height) {
                 $phpThumb->setParameter('h', $height);
             }
             $phpThumb->setParameter('config_output_format', 'jpeg');
             // set value to return
             $image = 'images/' . $itemType . '/' . str_replace(DS, '/', $date) . '/' . $item->id . '/' . $fileName;
             if ($phpThumb->GenerateThumbnail()) {
                 if ($image) {
                     if (!$phpThumb->RenderToFile($filepath)) {
                         // do something on failed
                         die('Failed (size=' . $width . '):<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>');
                     }
                     $phpThumb->purgeTempFiles();
                 }
             } else {
                 // do something with debug/error messages
                 echo 'Failed (size=' . $width . ').<br>';
                 echo '<div style="background-color:#FFEEDD; font-weight: bold; padding: 10px;">' . $phpThumb->fatalerror . '</div>';
                 echo '<form><textarea rows="100" cols="300" wrap="off">' . htmlentities(implode("\n* ", $phpThumb->debugmessages)) . '</textarea></form><hr>';
                 die;
             }
         } else {
             // set value to return
             $image = 'images/' . $itemType . '/' . str_replace(DS, '/', $date) . '/' . $item->id . '/' . $fileName;
         }
     } else {
         if (!$flagDelete) {
             $image = $item->images;
         }
     }
     return $image;
 }
开发者ID:ngxuanmui,项目名称:hanhphuc.vn,代码行数:92,代码来源:jnt_hanhphuc.php

示例7: explode

        @(list($key, $value) = explode('=', @$args[$i]));
        if (substr($key, -2) == '[]') {
            $_GET[substr($key, 0, -2)][] = $value;
        } else {
            $_GET[$key] = $value;
        }
    }
}
// instantiate a new phpThumb() object
ob_start();
if (!(include_once dirname(__FILE__) . '/phpthumb.class.php')) {
    ob_end_flush();
    die('failed to include_once("' . realpath(dirname(__FILE__) . '/phpthumb.class.php') . '")');
}
ob_end_clean();
$phpThumb = new phpThumb();
$phpThumb->DebugTimingMessage('phpThumb.php start', __FILE__, __LINE__, $starttime);
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[0]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '0') {
    $phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
if (file_exists(dirname(__FILE__) . '/phpThumb.config.php')) {
    ob_start();
    if (include_once dirname(__FILE__) . '/phpThumb.config.php') {
        // great
    } else {
        ob_end_flush();
        $phpThumb->ErrorImage('failed to include_once(' . dirname(__FILE__) . '/phpThumb.config.php) - realpath="' . realpath(dirname(__FILE__) . '/phpThumb.config.php') . '"');
开发者ID:BackupTheBerlios,项目名称:thinkedit-svn,代码行数:31,代码来源:phpThumb.php

示例8: array

// Example of how to use phpthumb.class.php as an object    //
//                                                          //
//////////////////////////////////////////////////////////////
// Note: phpThumb.php is where the caching code is located, if
//   you instantiate your own phpThumb() object that code is
//   bypassed and it's up to you to handle the reading and
//   writing of cached files.
require_once '../phpthumb.class.php';
// create 3 sizes of thumbnail
$thumbnail_widths = array(160, 320, 640);
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($_FILES['userfile']['tmp_name']);
    // or $phpThumb->setSourceData($binary_image_data);
    // 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;
开发者ID:kinj1987,项目名称:evo-league,代码行数:31,代码来源:phpThumb.demo.object.php

示例9: phpThumb

//        available at http://phpthumb.sourceforge.net     ///
//////////////////////////////////////////////////////////////
///                                                         //
// phpThumb.demo.object.php                                 //
// James Heinrich <info@silisoftware.com>                   //
//                                                          //
// Example of how to use phpthumb.class.php as an object    //
//                                                          //
//////////////////////////////////////////////////////////////
// Note: phpThumb.php is where the caching code is located, if
//   you instantiate your own phpThumb() object that code is
//   bypassed and it's up to you to handle the reading and
//   writing of cached files, if appropriate.
require_once '../phpthumb.class.php';
// create phpThumb object
$phpThumb = new phpThumb();
// create 3 sizes of thumbnail
$thumbnail_widths = array(160, 320, 640);
$capture_raw_data = false;
// set to true to insert to database rather than render to screen or file (see below)
foreach ($thumbnail_widths as $thumbnail_width) {
    // this is very important when using a single object to process multiple images
    $phpThumb->resetObject();
    // set data source -- do this first, any settings must be made AFTER this call
    $phpThumb->setSourceFilename('images/loco.jpg');
    // for static demo only
    //$phpThumb->setSourceFilename($_FILES['userfile']['tmp_name']);
    // or $phpThumb->setSourceData($binary_image_data);
    // or $phpThumb->setSourceImageResource($gd_image_resource);
    // PLEASE NOTE:
    // You must set any relevant config settings here. The phpThumb
开发者ID:ibouig,项目名称:Coordino,代码行数:31,代码来源:phpThumb.demo.object.php

示例10: uploadImg

function uploadImg($clib, $chkT, $selR)
{
    global $cfg;
    global $l;
    if (!$cfg['upload']) {
        return false;
    }
    foreach ($_FILES['nfile']['size'] as $key => $size) {
        if ($size > 0) {
            // get file extension and check for validity
            $ext = pathinfo($_FILES['nfile']['name'][$key]);
            $ext = strtolower($ext['extension']);
            if (!in_array($ext, $cfg['valid'])) {
                // invalid image
                echo $l->m('er_029');
                return false;
            }
            $path = str_replace('//', '/', $cfg['root_dir'] . $clib);
            // remove double slash in path
            $nfile = fixFileName($_FILES['nfile']['name'][$key]);
            // remove invalid characters in filename
            // move file to temp directory for processing
            if (!move_uploaded_file($_FILES['nfile']['tmp_name'][$key], $cfg['temp'] . '/' . $nfile)) {
                // upload image to temp dir
                echo $l->m('er_028');
                return false;
            }
            $size = getimagesize($cfg['temp'] . '/' . $nfile);
            // process (thumbnail) images
            $arr = $cfg['thumbs'];
            foreach ($arr as $key => $thumb) {
                if (in_array($key, $chkT)) {
                    // create new phpThumb() object
                    require_once dirname(__FILE__) . '/phpThumb/phpthumb.class.php';
                    $phpThumb = new phpThumb();
                    // create object
                    // parameters
                    $phpThumb->config_cache_disable_warning = true;
                    // disable cache warning
                    $phpThumb->config_output_format = $ext;
                    // output format
                    $phpThumb->src = $cfg['temp'] . '/' . $nfile;
                    // destination
                    $phpThumb->q = 95;
                    // compression level for jpeg
                    if ($selR != '') {
                        // set auto rotate
                        $phpThumb->ar = $selR;
                    }
                    //-------------------------------------------------------------------------
                    if ($thumb['size'] > 0 && ($size[0] >= $thumb['size'] || $size[1] >= $thumb['size'])) {
                        // size value is set -> RESIZING and source image is larger than preset sizes
                        // resize parameters
                        if ($size[0] < $size[1]) {
                            // portrait
                            $phpThumb->h = $thumb['size'];
                            // max. height
                        } else {
                            $phpThumb->w = $thumb['size'];
                            // max. width
                        }
                        // crop parameters
                        if ($thumb['crop'] == true) {
                            $phpThumb->zc = 1;
                            // set zoom crop
                            $phpThumb->w = $thumb['size'];
                            // width
                            $phpThumb->h = $thumb['size'];
                            // height
                        }
                        // create file suffix
                        if ($thumb['ext'] == '*') {
                            // image size is used
                            $dim = '_' . $thumb['size'];
                            // e.g. _1280
                        } else {
                            if ($thumb['ext'] == '') {
                                // no suffix is created
                                $dim = '';
                            } else {
                                // suffix is set to $thumb['ext']
                                $dim = '_' . $thumb['ext'];
                            }
                        }
                        //-------------------------------------------------------------------------
                    } elseif ($thumb['size'] == 0 || $thumb['size'] == '*') {
                        // size value is set to '0' -> NO RESIZING
                        // crop parameters
                        if ($thumb['crop'] == true) {
                            $phpThumb->zc = 1;
                            // set zoom crop
                            if ($size[0] < $size[1]) {
                                // portrait
                                $phpThumb->w = $size[0];
                                // getimagesize width value
                                $phpThumb->h = $size[0];
                                // getimagesize width value
                            } else {
                                // landscape
                                $phpThumb->w = $size[1];
//.........这里部分代码省略.........
开发者ID:burak-tekin,项目名称:CMScout2,代码行数:101,代码来源:rfiles.php

示例11: thumbnail

 /**
  * Create a thumbnail from an image, cache it and output it
  *
  * @param $imageName File name from webroot/uploads/
  */
 function thumbnail($imageName, $width = 120, $height = 120, $crop = 0)
 {
     $this->autoRender = false;
     $imageName = str_replace(array('..', '/'), '', $imageName);
     // Don't allow escaping to upper directories
     $width = intval($width);
     if ($width > 2560) {
         $width = 2560;
     }
     $height = intval($height);
     if ($height > 1600) {
         $height = 1600;
     }
     $cachedFileName = join('_', array($imageName, $width, $height, $crop)) . '.jpg';
     $cacheDir = Configure::read('Wildflower.thumbnailsCache');
     $cachedFilePath = $cacheDir . DS . $cachedFileName;
     $refreshCache = false;
     $cacheFileExists = file_exists($cachedFilePath);
     if ($cacheFileExists) {
         $cacheTimestamp = filemtime($cachedFilePath);
         $cachetime = 60 * 60 * 24 * 14;
         // 14 days
         $border = $cacheTimestamp + $cachetime;
         $now = time();
         if ($now > $border) {
             $refreshCache = true;
         }
     }
     if ($cacheFileExists && !$refreshCache) {
         return $this->_renderJpeg($cachedFilePath);
     } else {
         // Create cache and render it
         $sourceFile = Configure::read('Wildflower.uploadDirectory') . DS . $imageName;
         if (!file_exists($sourceFile)) {
             return trigger_error("Thumbnail generator: Source file {$sourceFile} does not exists.");
         }
         App::import('Vendor', 'phpThumb', array('file' => 'phpthumb.class.php'));
         $phpThumb = new phpThumb();
         $phpThumb->setSourceFilename($sourceFile);
         $phpThumb->setParameter('config_output_format', 'jpeg');
         $phpThumb->setParameter('w', intval($width));
         $phpThumb->setParameter('h', intval($height));
         $phpThumb->setParameter('zc', intval($crop));
         if ($phpThumb->GenerateThumbnail()) {
             $phpThumb->RenderToFile($cachedFilePath);
             return $this->_renderJpeg($cachedFilePath);
         } else {
             return trigger_error("Thumbnail generator: Can't GenerateThumbnail.");
         }
     }
 }
开发者ID:Jaciss,项目名称:wildflower,代码行数:56,代码来源:wild_assets_controller.php

示例12: die

    die('"magic_quotes_runtime" is set in php.ini, cannot run phpThumb with this enabled');
}
$starttime = array_sum(explode(' ', microtime()));
// this script relies on the superglobal arrays, fake it here for old PHP versions
if (phpversion() < '4.1.0') {
    $_SERVER = $HTTP_SERVER_VARS;
    $_GET = $HTTP_GET_VARS;
}
// instantiate a new phpThumb() object
ob_start();
if (!(include_once dirname(__FILE__) . '/phpthumb.class.php')) {
    ob_end_flush();
    die('failed to include_once("' . realpath(dirname(__FILE__) . '/phpthumb.class.php') . '")');
}
ob_end_clean();
$phpThumb = new phpThumb();
$phpThumb->DebugTimingMessage('phpThumb.php start', __FILE__, __LINE__, $starttime);
$phpThumb->SetParameter('config_error_die_on_error', true);
if (!phpthumb_functions::FunctionIsDisabled('set_time_limit')) {
    set_time_limit(60);
    // shouldn't take nearly this long in most cases, but with many filters and/or a slow server...
}
// phpThumbDebug[0] used to be here, but may reveal too much
// info when high_security_mode should be enabled (not set yet)
if (file_exists(dirname(__FILE__) . '/phpThumb.config.php')) {
    ob_start();
    if (include_once dirname(__FILE__) . '/phpThumb.config.php') {
        // great
    } else {
        ob_end_flush();
        $phpThumb->ErrorImage('failed to include_once(' . dirname(__FILE__) . '/phpThumb.config.php) - realpath="' . realpath(dirname(__FILE__) . '/phpThumb.config.php') . '"');
开发者ID:CrazyBobik,项目名称:allotaxi.test,代码行数:31,代码来源:phpThumb.php

示例13: aux_image

function aux_image($fieldValue, $params_image)
{
    $md5_params = md5($params_image);
    if (file_exists(MF_FILES_PATH . 'th_' . $md5_params . "_" . $fieldValue)) {
        $fieldValue = MF_FILES_URI . 'th_' . $md5_params . "_" . $fieldValue;
    } else {
        //generate thumb
        include_once dirname(__FILE__) . "/thirdparty/phpthumb/phpthumb.class.php";
        $phpThumb = new phpThumb();
        $phpThumb->setSourceFilename(MF_FILES_PATH . $fieldValue);
        $create_md5_filename = 'th_' . $md5_params . "_" . $fieldValue;
        $output_filename = MF_FILES_PATH . $create_md5_filename;
        $final_filename = MF_FILES_URI . $create_md5_filename;
        $params_image = explode("&", $params_image);
        foreach ($params_image as $param) {
            if ($param) {
                $p_image = explode("=", $param);
                $phpThumb->setParameter($p_image[0], $p_image[1]);
            }
        }
        if ($phpThumb->GenerateThumbnail()) {
            if ($phpThumb->RenderToFile($output_filename)) {
                $fieldValue = $final_filename;
            }
        }
    }
    return $fieldValue;
}
开发者ID:blackparallax,项目名称:living-stories.wordpress,代码行数:28,代码来源:get-custom.php

示例14: getPhotoFromUrl

 protected function getPhotoFromUrl($url, $size = null)
 {
     Yii::import('application.vendors.*');
     // Yii::import('ext.phpthumbnew.*');
     require_once '/phpthumb/phpthumb.class.php';
     // Yii::setPathOfAlias('phpthumb',Yii::getPathOfAlias('application.vendors.phpthumb.phpthumb.class.php'));
     $extention = 'jpg';
     $id_photo = time();
     $file_name = $id_photo . '.' . $extention;
     $upload_path = Yii::getPathOfAlias(Yii::app()->params['storeImages']['tmp']) . DIRECTORY_SEPARATOR . $file_name;
     $PT = new phpThumb();
     if ($size) {
         $sizes = explode('x', $size);
         $w = $sizes[0];
         $h = $sizes[1];
         $PT->w = (int) $w;
         $PT->h = (int) $h;
     }
     $PT->src = $url;
     $PT->bg = "#ffffff";
     $PT->q = 90;
     $PT->far = false;
     $PT->f = $extention;
     $PT->GenerateThumbnail();
     $success = $PT->RenderToFile($upload_path);
     if ($success) {
         return $id_photo . '.' . $extention;
     } else {
         return false;
     }
 }
开发者ID:Aplay,项目名称:myhistorypark_site,代码行数:31,代码来源:FileBehavior.php

示例15: phpThumb

<?php

//////////////////////////////////////////////////////////////
///  phpThumb() by James Heinrich <info@silisoftware.com>   //
//        available at http://phpthumb.sourceforge.net     ///
//////////////////////////////////////////////////////////////
///                                                         //
// phpThumb.demo.object.simple.php                          //
// James Heinrich <info@silisoftware.com>                   //
//                                                          //
// Simplified example of how to use phpthumb.class.php as   //
// an object -- please also see phpThumb.demo.object.php    //
//                                                          //
//////////////////////////////////////////////////////////////
require_once '../phpthumb.class.php';
$phpThumb = new phpThumb();
// set data
$phpThumb->setSourceFilename($_FILES['userfile']['tmp_name']);
// set parameters (see "URL Parameters" in phpthumb.readme.txt)
$phpThumb->setParameter('w', $thumbnail_width);
// 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 ($phpThumb->RenderToFile($output_filename)) {
        // do something on success
        echo 'Successfully rendered to "' . $output_filename . '"';
    } else {
        // do something with debug/error messages
        echo 'Failed:<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>';
    }
开发者ID:Zunair,项目名称:xataface,代码行数:31,代码来源:phpThumb.demo.object.simple.php


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