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


PHP phpThumb::setParameter方法代码示例

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


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

示例2: 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

示例3: 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

示例4: 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

示例5: resizeImage

 /**
  * Resize an image
  *
  * Looks like a private function to me, but could be used as it is
  * 
  * @param $filename String Nom du fichier
  * @param $options Array Can override $settings and add these options :
  *				output : relative to 'folder' output image filename (default : $filename (overwrite))
  *				delete_source : if output is different from input, this set to true will delete the source file (default : false)
  * @return Returns true in case of success, false otherwise ($this->errors[$Model->name] gets populated)
  */
 function resizeImage(&$Model, $filepath, $options = array())
 {
     if (!file_exists($filepath)) {
         $this->errors[$Model->name][] = __('PhpThumb behavior : le fichier ', true) . $filepath . __(' n\'existe pas.', true);
         return false;
     }
     $settings = am(am($this->settings[$Model->name]['default'], array('output' => $filepath, 'delete_source' => false)), $options);
     App::import('Vendor', 'phpThumb', array('file' => 'phpThumb' . DS . 'phpthumb.class.php'));
     $phpThumb = new phpThumb();
     $phpThumb->setSourceFilename($filepath);
     $phpThumb->setParameter('w', $settings['width']);
     $phpThumb->setParameter('h', $settings['height']);
     if ($settings['zoomcrop'] === true) {
         //$phpThumb->setParameter('zc', 1);
     }
     if (!(0 == $settings['sx'] && 0 == $settings['sy'] && 0 == $settings['sw'] && 0 == $settings['sh'])) {
         $phpThumb->setParameter('sx', $settings['sx']);
         $phpThumb->setParameter('sy', $settings['sy']);
         $phpThumb->setParameter('sw', $settings['sw']);
         $phpThumb->setParameter('sh', $settings['sh']);
         if ($settings['aoe']) {
             $phpThumb->setParameter('aoe', 1);
         }
     }
     if (isset($settings['f'])) {
         $phpThumb->setParameter('f', $settings['f']);
     }
     if (!$phpThumb->generateThumbnail()) {
         /* Woopsy, the image couldn't be resized */
         debug($phpThumb->debugmessages);
         $this->errors[$Model->name][] = __('PhpThumb behavior : le fichier ', true) . $filepath . __(' n\'a pas pu être resizé', true);
         return false;
     }
     if (!$phpThumb->RenderToFile($settings['output'])) {
         /* File couldn't be created */
         $this->errors[$Model->name][] = __('PhpThumb behavior : le fichier ', true) . $settings['folder'] . $settings['output'] . __(' n\'a pas pu être créé', true);
         return false;
     }
     if ($settings['delete_source'] && $settings['output'] != $filepath) {
         if (!unlink($filepath)) {
             $this->errors[$Model->name][] = __('PhpThumb behavior : le fichier ', true) . $filepath . __(' n\'a pas pu être supprimé', true);
             return false;
         }
     }
     return true;
 }
开发者ID:kouak,项目名称:ircube,代码行数:57,代码来源:php_thumb.php

示例6: die

            @readfile($phpThumb->cache_filename);
        }
        exit;
    }
    return true;
}
// 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->config_disable_debug = false;
        // otherwise error message won't print
        $phpThumb->ErrorImage('failed to include_once(' . dirname(__FILE__) . '/phpThumb.config.php) - realpath="' . realpath(dirname(__FILE__) . '/phpThumb.config.php') . '"');
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:31,代码来源:phpThumb.php

示例7: dirname

        $phpThumb->ErrorImage('failed to include_once(' . dirname(__FILE__) . '/phpThumb.config.php) - realpath="' . realpath(dirname(__FILE__) . '/phpThumb.config.php') . '"');
    }
    ob_end_clean();
} elseif (file_exists(dirname(__FILE__) . '/phpThumb.config.php.default')) {
    $phpThumb->config_disable_debug = false;
    // otherwise error message won't print
    $phpThumb->ErrorImage('Please rename "phpThumb.config.php.default" to "phpThumb.config.php"');
} else {
    $phpThumb->config_disable_debug = false;
    // otherwise error message won't print
    $phpThumb->ErrorImage('failed to include_once(' . dirname(__FILE__) . '/phpThumb.config.php) - realpath="' . realpath(dirname(__FILE__) . '/phpThumb.config.php') . '"');
}
if (!empty($PHPTHUMB_CONFIG)) {
    foreach ($PHPTHUMB_CONFIG as $key => $value) {
        $keyname = 'config_' . $key;
        $phpThumb->setParameter($keyname, $value);
        if (!preg_match('#(password|mysql)#i', $key)) {
            $phpThumb->DebugMessage('setParameter(' . $keyname . ', ' . $phpThumb->phpThumbDebugVarDump($value) . ')', __FILE__, __LINE__);
        }
    }
    if (!$phpThumb->config_disable_debug) {
        // if debug mode is enabled, force phpThumbDebug output, do not allow normal thumbnails to be generated
        $_GET['phpThumbDebug'] = !empty($_GET['phpThumbDebug']) ? max(1, intval($_GET['phpThumbDebug'])) : 9;
        $phpThumb->setParameter('phpThumbDebug', $_GET['phpThumbDebug']);
    }
} else {
    $phpThumb->DebugMessage('$PHPTHUMB_CONFIG is empty', __FILE__, __LINE__);
}
if (empty($phpThumb->config_disable_pathinfo_parsing) && (empty($_GET) || isset($_GET['phpThumbDebug'])) && !empty($_SERVER['PATH_INFO'])) {
    $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', @$_SERVER['PHP_SELF']);
    $args = explode(';', substr($_SERVER['PATH_INFO'], 1));
开发者ID:RHoKAustralia,项目名称:onaroll21,代码行数:31,代码来源:phpThumb.php

示例8: action_zip

 public function action_zip($articulo_id)
 {
     include DOCROOT . 'phpthumb/phpthumb.class.php';
     \Config::load('phpthumb');
     $document_root = str_replace("\\", "/", Config::get('document_root'));
     is_null($articulo_id) and Response::redirect('articulo');
     $articulo = Model_Articulo::find('first', array('related' => array('fotos', 'seccion'), 'where' => array(array('id', '=', $articulo_id))));
     $fotos_web = null;
     foreach ($articulo->fotos as $foto) {
         $phpThumb = new phpThumb();
         $phpThumb->setParameter('w', Config::get('web_size'));
         $phpThumb->setParameter('q', 75);
         $phpThumb->setParameter('aoe', true);
         $phpThumb->setParameter('config_output_format', 'jpeg');
         $phpThumb->setParameter('f', 'jpeg');
         $nombre_archivo = str_ireplace(".jpg", Config::get('photos_texto') . '.jpg', $foto->imagen);
         $pieces = explode("/", $nombre_archivo);
         $count_foto = count($pieces);
         $nombre_archivo = $pieces[$count_foto - 1];
         $output_filename = $document_root . "/web/" . $nombre_archivo;
         $phpThumb->setSourceData(file_get_contents($document_root . $foto->imagen));
         if ($phpThumb->GenerateThumbnail()) {
             if ($phpThumb->RenderToFile($output_filename)) {
                 Log::info('Imagen para web generada con exito' . $output_filename);
                 $fotos_web[] = $output_filename;
             } else {
                 Log::info('Error al generar imagen para web ' . $phpThumb->debugmessages);
             }
             $phpThumb->purgeTempFiles();
         } else {
             Log::info('Error Fatal al generar imagen para web ' . $phpThumb->fatalerror . "|" . $phpThumb->debugmessages);
         }
         unset($phpThumb);
     }
     $time = time();
     Zip::create_zip($fotos_web, $articulo_id, true, $time);
 }
开发者ID:ronaldpatino,项目名称:fuelphp-auth,代码行数:37,代码来源:foto.php

示例9: processEPC

function processEPC($photo, $dea_id)
{
    require_once dirname(__FILE__) . "/phpThumb/phpthumb.class.php";
    $errors = '';
    $thumbnail_sizes = array('full' => array('h' => '600'), 'large' => array('h' => '600'), 'small' => array('w' => '200'), 'thumb1' => array('w' => '146', 'h' => '146'), 'original' => array('h' => '', 'w' => ''));
    $image_path_property = IMAGE_PATH_PROPERTY . $dea_id . "/";
    $image_url_property = IMAGE_URL_PROPERTY . $dea_id . "/";
    $attributes = getimagesize($image_path_property . $photo);
    foreach ($thumbnail_sizes as $ext => $dims) {
        if (isset($dims['w']) && $dims['w']) {
            $dims['w'] = $attributes[0] < $dims['w'] ? $attributes[0] : $dims['w'];
        }
        if (isset($dims['h']) && $dims['h']) {
            $dims['h'] = $attributes[1] < $dims['h'] ? $attributes[1] : $dims['h'];
        }
        // only process images that are big enough
        $phpThumb = new phpThumb();
        // set data
        $phpThumb->setSourceFilename($image_path_property . $photo);
        if (isset($dims['w']) && $dims['w']) {
            $phpThumb->setParameter('w', $dims['w']);
        }
        if (isset($dims['h']) && $dims['h']) {
            $phpThumb->setParameter('h', $dims['h']);
        }
        $phpThumb->setParameter('config_output_format', 'gif');
        $phpThumb->setParameter('config_allow_src_above_docroot', true);
        // generate & output thumbnail
        $output_filename = $image_path_property . str_replace('.gif', '', $photo) . '_' . $ext . '.' . $phpThumb->config_output_format;
        if ($phpThumb->GenerateThumbnail()) {
            // this line is VERY important, do not remove it!
            $output_size_x = ImageSX($phpThumb->gdimg_output);
            $output_size_y = ImageSY($phpThumb->gdimg_output);
            if ($output_filename) {
                if ($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
            $errors .= '<p>Failed (size=' . $thumbnail_width . ').<br>
				<div style="background-color:#FFEEDD; font-weight: bold; padding: 10px;">' . $phpThumb->fatalerror . '</div>
				<form><textarea rows="10" cols="60" wrap="off">' . htmlentities(implode("\n* ", $phpThumb->debugmessages)) . '</textarea></form></p><hr>';
        }
    }
    if ($errors) {
        echo $errors;
        exit;
    }
}
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:56,代码来源:image.inc.php

示例10: 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

示例11: die

        if (is_readable($SourceFilename)) {
            $md5s = phpthumb_functions::md5_file_safe($SourceFilename);
        } else {
            $phpThumb->ErrorImage('ERROR: "' . $SourceFilename . '" cannot be read');
        }
    }
    if (@$_SERVER['HTTP_REFERER']) {
        $phpThumb->ErrorImage('&md5s=' . $md5s);
    } else {
        die('&md5s=' . $md5s);
    }
}
if (!empty($PHPTHUMB_CONFIG)) {
    foreach ($PHPTHUMB_CONFIG as $key => $value) {
        $keyname = 'config_' . $key;
        $phpThumb->setParameter($keyname, $value);
        if (!preg_match('/password/i', $key)) {
            $phpThumb->DebugMessage('setParameter(' . $keyname . ', ' . $phpThumb->phpThumbDebugVarDump($value) . ')', __FILE__, __LINE__);
        }
    }
} else {
    $phpThumb->DebugMessage('$PHPTHUMB_CONFIG is empty', __FILE__, __LINE__);
}
if (@$_GET['src'] && !@$PHPTHUMB_CONFIG['allow_local_http_src'] && preg_match('/^http\\:\\/\\/' . @$_SERVER['HTTP_HOST'] . '(.+)/i', @$_GET['src'], $matches)) {
    $phpThumb->ErrorImage('It is MUCH better to specify the "src" parameter as "' . $matches[1] . '" instead of "' . $matches[0] . '".' . "\n\n" . 'If you really must do it this way, enable "allow_local_http_src" in phpThumb.config.php');
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[1]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '1') {
    $phpThumb->phpThumbDebug();
开发者ID:CrazyBobik,项目名称:allotaxi.test,代码行数:31,代码来源:phpThumb.php

示例12: _thumbnail

 private function _thumbnail($maxwidth, $maxheight, $crop = false, $quality = 90)
 {
     $stack = $this->stack ? $this->stack : $this->resultset->get_stack();
     if (!isset($this->thumbnails)) {
         $this->thumbnails = array();
     } else {
         if (is_string($this->thumbnails)) {
             $this->thumbnails = array_filter(explode(';', $this->thumbnails));
         }
     }
     $slugname = 'slug_' . language();
     if (isset($this->{$slugname})) {
         $this->slug = $this->{$slugname};
     }
     $file_path = get_file_directory(str_replace('>', '/', $stack));
     $file_url = get_file_url(str_replace('>', '/', $stack));
     $target = $this->id . '-' . intval($maxwidth) . 'x' . intval($maxheight);
     $extension = strtolower(substr($this->filename, strrpos($this->filename, '.') + 1));
     $file = $this->slug . '-' . $this->id . '-' . intval($maxwidth) . '-' . intval($maxheight);
     $thumbcheck = language() . intval($maxwidth) . 'x' . intval($maxheight) . ($crop ? 'c' : '');
     if ($crop) {
         $file .= '-c';
         $target .= '-c';
     }
     $file .= '.' . $extension;
     $target .= '.' . $extension;
     if (!in_array($thumbcheck, $this->thumbnails)) {
         $valid = true;
         if (strstr($this->filename, '://')) {
             if (!fopen($this->filename, "r")) {
                 $valid = false;
             }
         } else {
             if (strstr($this->filename, $_SERVER['DOCUMENT_ROOT'])) {
                 if (!file_exists($this->filename)) {
                     $valid = false;
                 }
             } else {
                 if (!$this->filename || !file_exists(FILESPATH . $this->filename)) {
                     $valid = false;
                 }
             }
         }
         if (!$valid) {
             $this->filename = BASEPATH . 'nopic.jpg';
             $file = $this->id . '-nopic-' . intval($maxwidth) . 'x' . intval($maxheight);
             $target = $this->id . '-nopic-' . intval($maxwidth) . 'x' . intval($maxheight);
             if ($crop) {
                 $file .= '-c';
                 $target .= '-c';
             }
             $file .= '.' . $extension;
             $target .= '.' . $extension;
         }
         require_once 'phpthumb/phpthumb.class.php';
         $phpThumb = new phpThumb();
         if (strstr($this->filename, '://') || strstr($this->filename, $_SERVER['DOCUMENT_ROOT'])) {
             $phpThumb->setSourceFilename($this->filename);
         } else {
             $phpThumb->setSourceFilename(FILESPATH . $this->filename);
         }
         $phpThumb->setParameter('w', $maxwidth);
         $phpThumb->setParameter('h', $maxheight);
         $phpThumb->setParameter('f', strtolower($extension));
         if (is_numeric($quality)) {
             $phpThumb->setParameter('q', $quality);
         } else {
             $bytes = intval($quality);
             if (stristr($quality, 'mb')) {
                 $bytes *= 1024 * 1024;
             } else {
                 if (stristr($quality, 'kb')) {
                     $bytes *= 1024;
                 }
             }
             $phpThumb->setParameter('maxb', $bytes);
         }
         if ($crop) {
             $phpThumb->setParameter('zc', true);
             $phpThumb->setParameter('aoe', 1);
             $phpThumb->setParameter('far', 'C');
         }
         $output_filename = $file_path . $target;
         $success = false;
         if (file_exists($output_filename)) {
             $success = true;
         } else {
             if ($phpThumb->GenerateThumbnail()) {
                 $success = $phpThumb->RenderToFile($output_filename);
             }
         }
         if ($success) {
             @symlink($file_path . $target, $file_path . $file);
             if (!$this->path && $this->resultset) {
                 $this->path = $this->resultset->get_stack();
             }
             if ($this->id && $this->thumbnails_field && $this->path) {
                 $this->thumbnails[] = $thumbcheck;
                 where('id = %d', $this->id)->update($this->path, array($this->thumbnails_field => implode(';', $this->thumbnails)));
             }
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:Swevers,代码行数:101,代码来源:image.php

示例13: 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

示例14: thumb

 /**
  * Generate a thumbnail of an attachment
  * @param $file
  * @param $size
  * @return bool
  * @throws CException
  */
 public function thumb($file, $size)
 {
     if (!$file) {
         return false;
     }
     if (file_exists($file)) {
         return true;
     }
     if (!file_exists(dirname($file))) {
         mkdir(dirname($file), 0777, true);
     }
     // find the image
     $image = $this->getAttachmentFile();
     $defaultImage = dirname(Yii::app()->basePath) . '/data/attachment/default.jpg';
     if (!$image) {
         if (YII_DEBUG) {
             throw new CException('Cannot find source image (' . $image . ').');
         }
         $image = $defaultImage;
     }
     $fileInfo = pathinfo($image);
     if ($fileInfo['extension'] != 'pdf') {
         $imageSize = getimagesize($image);
         if ($imageSize[0] < $size[0]) {
             $size[0] = $imageSize[0];
         }
         if ($imageSize[1] < $size[1]) {
             $size[1] = $imageSize[1];
         }
     }
     require_once Yii::getPathOfAlias('vendor') . DIRECTORY_SEPARATOR . 'phpThumb' . DIRECTORY_SEPARATOR . 'phpThumb.php';
     $phpThumb = new phpThumb();
     $phpThumb->setSourceFilename($image);
     $phpThumb->setParameter('config_imagemagick_path', 'convert');
     $phpThumb->setParameter('config_allow_src_above_docroot', 'convert');
     $phpThumb->setParameter('aoe', false);
     $phpThumb->setParameter('w', $size[0]);
     $phpThumb->setParameter('h', $size[1]);
     $phpThumb->setParameter('f', 'JPG');
     // set the output format
     $phpThumb->setParameter('far', 'C');
     // scale outside
     $phpThumb->setParameter('bg', 'FFFFFF');
     // scale outside
     if (!$phpThumb->GenerateThumbnail()) {
         $phpThumb->setSourceFilename($defaultImage);
         if (!$phpThumb->GenerateThumbnail()) {
             throw new CException('Cannot generate thumbnail from image (' . $image . ').');
         }
     }
     if (!$phpThumb->RenderToFile($file)) {
         throw new CException('Cannot save thumbnail (' . $file . ').');
     }
     return true;
 }
开发者ID:cornernote,项目名称:yii-dressing,代码行数:62,代码来源:YdAttachment.php

示例15: PhotosPage

 if (@(!empty($_POST['delicious_username']))) {
     $l->addMember($_POST['delicious_username'], "", "delicious");
 }
 if (@(!empty($_POST['reddit_username']))) {
     $l->addMember($_POST['reddit_username'], "", "reddit");
 }
 if (@(!empty($_POST['flickr_username']))) {
     include_once 'includes/Page.PhotosYYY.class.php';
     $p = new PhotosPage($group_name);
     @$p->changePersonalFlickrAccount($u->getID(), $_POST['flickr_username']);
 }
 if (isset($_FILES['avatar'])) {
     include_once 'includes/phpThumb/phpthumb.class.php';
     include_once 'includes/custom_avatar.inc.php';
     $phpThumb = new phpThumb();
     $phpThumb->setParameter('config_allow_src_above_docroot', true);
     // very important
     $phpThumb->setSourceFilename($_FILES['avatar']['tmp_name']);
     $phpThumb->setParameter('w', 80);
     $phpThumb->setParameter('h', 80);
     $phpThumb->setParameter('zc', 1);
     $phpThumb->setParameter('config_output_format', 'png');
     if ($phpThumb->GenerateThumbnail()) {
         include_once 'configs/globals.php';
         $membership_id = $u->getMembershipID($group_name);
         $bigfile = $app_base . "avatars/{$membership_id}/80.png";
         $smallfile = $app_base . "avatars/{$membership_id}/16.png";
         $target = $app_base . "avatars/{$membership_id}/";
         @mkdir($target);
         $phpThumb->RenderToFile($bigfile);
         makeSmallAvatar($bigfile, $smallfile);
开发者ID:esokullu,项目名称:grou.ps,代码行数:31,代码来源:index.php


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