Beispiel #1
0
 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}'/>";
 }
 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');
                 }
             }
         }
     }
 }
$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
 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');
     }
 }
 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');
             }
         }
     }
 }