本文整理汇总了PHP中Thumbnail::size方法的典型用法代码示例。如果您正苦于以下问题:PHP Thumbnail::size方法的具体用法?PHP Thumbnail::size怎么用?PHP Thumbnail::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thumbnail
的用法示例。
在下文中一共展示了Thumbnail::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: thumbnail
function thumbnail($filename, $width = 640, $height = 480)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$source = "/media/com_arcnaanimals/{$filename}";
if (!JFile::exists(JPATH_ROOT . $source)) {
return false;
}
$destination = "/media/com_arcnaanimals/thumbs/{$width}_{$height}_{$filename}";
if (!JFile::exists(JPATH_ROOT . $destination)) {
if (!JFolder::exists(dirname(JPATH_ROOT . $destination))) {
JFolder::create(dirname(JPATH_ROOT . $destination));
}
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/thumbnail/Thumbnail.class.php';
$thumb = new Thumbnail(JPATH_ROOT . $source);
// Contructor and set source image file
$thumb->size($width, $height);
// [OPTIONAL] set the biggest width and height for thumbnail
$thumb->process();
// generate image
// save the file
ob_start();
$thumb->show();
$output = ob_get_contents();
ob_end_clean();
JFile::write(JPATH_ROOT . $destination, $output);
}
$url = JURI::root(true) . $destination;
return "<img src='{$url}' alt='{$filename}'/>";
}
示例2: createThumbs
protected function createThumbs($file, $targets)
{
global $eshop_picture_config;
$dir_photo = KIWI_DIR_PRODUCTS;
foreach ($targets as $target) {
if (!array_key_exists($target, $eshop_picture_config)) {
throw new Exception('Für das Vorschaubild Ziel unbekannt');
}
if (is_array($eshop_picture_config[$target])) {
$t = new Thumbnail("{$dir_photo}photo/{$file}");
$t->size($eshop_picture_config[$target][0], $eshop_picture_config[$target][1]);
$t->quality = 80;
$t->output_format = 'JPG';
$this->log("Erstellen einer Miniaturansicht zu das Bild {$file} in das Verzeichnis {$target}");
$t->process();
if (!$this->_simulation) {
$status = $t->save("{$dir_photo}{$target}/{$file}");
if (!$status) {
throw new Exception('Fehler beim Speichern einer Miniaturansicht des Bildes');
}
}
}
}
}
示例3:
$thumb->allow_enlarge=false; // [OPTIONAL] allow to enlarge the thumbnail
//$thumb->CalculateQFactor(10000); // [OPTIONAL] Calculate JPEG quality factor for a specific size in bytes
//$thumb->bicubic_resample=false; // [OPTIONAL] set resample algorithm to bicubic
*/
$thumb->img_watermark = 'watermark.png';
// [OPTIONAL] set watermark source file, only PNG format [RECOMENDED ONLY WITH GD 2 ]
/*
$thumb->img_watermark_Valing='TOP'; // [OPTIONAL] set watermark vertical position, TOP | CENTER | BOTTON
$thumb->img_watermark_Haling='LEFT'; // [OPTIONAL] set watermark horizonatal position, LEFT | CENTER | RIGHT
$thumb->txt_watermark='Watermark Text'; // [OPTIONAL] set watermark text [RECOMENDED ONLY WITH GD 2 ]
$thumb->txt_watermark_color='FF0000'; // [OPTIONAL] set watermark text color , RGB Hexadecimal[RECOMENDED ONLY WITH GD 2 ]
$thumb->txt_watermark_font=5; // [OPTIONAL] set watermark text font: 1,2,3,4,5
$thumb->txt_watermark_Valing='BOTTOM'; // [OPTIONAL] set watermark text vertical position, TOP | CENTER | BOTTOM
$thumb->txt_watermark_Haling='RIGHT'; // [OPTIONAL] set watermark text horizonatal position, LEFT | CENTER | RIGHT
$thumb->txt_watermark_Hmargin=10; // [OPTIONAL] set watermark text horizonatal margin in pixels
$thumb->txt_watermark_Vmargin=10; // [OPTIONAL] set watermark text vertical margin in pixels
$thumb->size_width(150); // [OPTIONAL] set width for thumbnail, or
$thumb->size_height(113); // [OPTIONAL] set height for thumbnail, or
$thumb->size_auto(150); // [OPTIONAL] set the biggest width or height for thumbnail
*/
$thumb->size(150, 113);
// [OPTIONAL] set the biggest width and height for thumbnail
$thumb->process();
// generate image
$thumb->show();
// show your thumbnail, or
//$thumb->save("thumbnail.".$thumb->output_format); // save your thumbnail to file, or
//$image = $thumb->dump(); // get the image
//echo ($thumb->error_msg); // print Error Mensage
示例4: scalePicture
protected function scalePicture($file)
{
global $eshop_picture_config;
$t = new Thumbnail(KIWI_DIR_ACTIONS_PIC . $file);
$t->size($eshop_picture_config['action'][0], $eshop_picture_config['action'][1]);
$t->quality = 80;
$t->output_format = 'JPG';
$t->process();
$status = $t->save(KIWI_DIR_ACTIONS_PIC . $file);
if (!$status) {
throw new Exception('Chyba při ukládání miniatury obrázku');
}
}
示例5: createThumbs
protected function createThumbs($file, $targets)
{
global $eshop_picture_config;
$dir_photo = KIWI_DIR_PRODUCTS;
foreach ($targets as $target) {
if (!array_key_exists($target, $eshop_picture_config)) {
throw new Exception('Neznámý cíl pro miniaturu fotografie');
}
if (is_array($eshop_picture_config[$target])) {
$t = new Thumbnail("{$dir_photo}photo/{$file}");
$t->size($eshop_picture_config[$target][0], $eshop_picture_config[$target][1]);
$t->quality = 80;
$t->output_format = 'JPG';
$t->process();
$status = $t->save("{$dir_photo}{$target}/{$file}");
if (!$status) {
throw new Exception('Chyba při ukládání miniatury obrázku');
}
}
}
}