Russian TYPO3 community Форум больше не используется. Присоединяйтесь к каналу #community-ru в Slack for TYPO3 community  

Вернуться   Russian TYPO3 community > Тематические форумы > TypoScript практикум

Ответ
 
Опции темы Опции просмотра
Старый 16.08.2007, 04:08   #1
enot
Новенький
 
Регистрация: 02.11.2006
Сообщений: 24
По умолчанию маска на картинку

вот пытаюсь наложить логотипчик на картинку

$conf["image."]["file"] = "uploads/tx_ed/".$data['file'];
$conf["image."]["file."]["height"] = $height.'m';
$conf["image."]["file."]["width"] = $widht.'m';
$conf["image."]["imageLinkWrap"] = '1';
$conf["image."]["altText"] = $title;
$conf["image."]["titleText"] = $title;
// $conf["image."]['wrap'] = ' | '.$data['title'];
$conf["image."]["file."]["m."]["bgImg"] = "fileadmin/templates/ed/watermark2.jpg";
$conf["image."]["file."]["m."]["mask"] = "fileadmin/templates/ed/mask_whited.gif";
$conf["image."]["imageLinkWrap."]["enable"] = "1";
$conf["image."]["imageLinkWrap."]["bodyTag"] = "<BODY style=\"margin:4 4 4 4;\">";//.Pictures::getCounters();
$conf["image."]["imageLinkWrap."]["wrap"] = "<A title=\"".htmlspecialchars($title)."\" href=\"javascript:close();\"> | </A>";



$conf["image."]["imageLinkWrap."]["width"] = "800m";
$conf["image."]["imageLinkWrap."]["height"] = "600m";
$conf["image."]["imageLinkWrap."]["title"] = $title;
$conf["image."]["imageLinkWrap."]["JSwindow"] = "1";
$conf["image."]["imageLinkWrap."]["JSwindow."]["newWindow"] = "1";
$conf["image."]["imageLinkWrap."]["JSwindow."]["expand"] = "8,8";



$theImgCode=$cObj->IMAGE($conf["image."]);

вот такой код...
на уменьшенную картинку логотипчик наложился а на большую (та что октрывается в новом окне) нет.
в чем ошибка? и можно ли так вообще делать?
enot вне форума   Ответить с цитированием
Старый 16.08.2007, 23:09   #2
Valery Romanchev
Administrator
 
Аватар для Valery Romanchev
 
Регистрация: 23.08.2003
Адрес: Moscow, Russia
Сообщений: 1,926
Отправить сообщение для Valery Romanchev с помощью Skype™
По умолчанию

сделать нормальное наложение логотипа с помощью тайповских библиотек, которые дергают imagemagic - довольно проблематично.
(особенно, если у клиента высокие требования к результату)

Я пробовал года полтора назад

В итоге - сделал обычным PHP кодом с использованием GD

PHP код:
 <?php
/**
 * Provide TCE and TCEforms functions for usage in own extension.
 * 
 * @package TYPO3
 */
class tx_netshop_images {

     
/**
      * function resizeImage($width, $height, $source, $target)
      * Resizes the Image to the given values
      * 
      * @param     width     int          The maximum image width
      * @param     height     int          The maximum image height
      * @param     source     String     The source file
      * @param     target     String     The target file
      * 
      * @return      void
      */
     //          $dim_thumb=tx_netshop_images::imageResize('130', '170', '85', $fullname,$width, $height, $folderCurrent.'thumb/'.$item->data['item_id'].'.jpg');


     //     function imageResize($width, $height, $quality, $source, $width_orig, $height_orig, $target) {

     
function imageResize($code$source$target) {

          if (!
is_file($source)) return array(0,0);
          
          switch (
$code){
               case 
'thumb':
                    
$width=130;
                    
$height=170;
                    
$quality=85;
                    break;
               case 
'small':
                    
$width=50;
                    
$height=60;
                    
$quality=85;
                    break;
          }

          list(
$width_orig$height_orig$type$attr) = @getimagesize($source);
          if (!
$width_orig) return array(100,100);

          
//width and maxH
          
$height_cur round(($width $width_orig) * $height_orig);
          if (
$height_cur $height){
               
$widthround(($height $height_orig) * $width_orig);
          }
          else {
               
$height=$height_cur;
          }

          
//          debug(array($width, $height, $quality, $source, $width_orig, $height_orig, $target));
          // Resample
          
$image_p imagecreatetruecolor($width$height);
          
$image imagecreatefromjpeg($source);
          
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig);
          
// Output
          
imagedestroy($image);
          
imagejpeg($image_p$target$quality);
          
imagedestroy($image_p);

          return array(
$width,$height);
     }

     function 
imageMakeWatermark ($source$target) {

          
$quality=85;

          list(
$width_orig$height_orig$type$attr) = @getimagesize($source);

          if (
$width_orig == $height_orig) {
               
//               $orientation = 'square';
               
$width=min(450,$width_orig); //'450';

          
} elseif ($width_orig $height_orig ) {
               
//               $orientation = 'landscape';
               
$width=min(580,$width_orig);
          } else {
               
//               $orientation = 'portret';
               
$width=min(368,$width_orig);
          }


          
//width of the target is given only
          
$height round(($width $width_orig) * $height_orig);


          
//          t3lib_div::debug($source,'source');
          //          t3lib_div::debug($target,'target');
          
if (intval($width_orig) < 350){
               
$watermark imagecreatefrompng(PATH_site.'fileadmin/design/images/watermarkors_small.png');
               
$watermark_width '250';
               
$watermark_height '114';
          }
          else{
               
$watermark imagecreatefrompng(PATH_site.'fileadmin/design/images/watermarkors_sm.png');
               
$watermark_width '350';
               
$watermark_height '159';
          }
          
//          $image = imagecreatetruecolor($watermark_width, $watermark_height);
          
$image imagecreatefromjpeg($source);
          
$image_p imagecreatetruecolor($width$height);
          
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig);
          
// Output
          
imagedestroy($image);


          
$dest_x = ($width 2) - ($watermark_width 2);
          
$dest_y = ($height 2) - ($watermark_height 2);

          
//imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
          
imagecopy($image_p$watermark$dest_x $dest_y00$watermark_width$watermark_height);
          
//           imagecopyresampled($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height,
          //$watermark_width, $watermark_height);
          
imagedestroy($watermark);

          
imagejpeg($image_p,$target);
          
imagedestroy($image_p);
          return array(
$width,$height);
     }


     function 
imageUpdateSize($type$uid$width$height) {
          
// $type can be '', 'thumb', 'small', 'water'
          // Update clicks and click_ip of the link
          
$whereClause "uid=$uid";
          if(
$type$type='_'.$type;
          
$updateFields = array(
          
'width'.$type => $width,
          
'height'.$type => $height,
          );
          
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_netshop_items'  $whereClause$updateFields);
     }


     
     function 
createFolders($folderCurrent) {
if (
$folderCurrent!=PATH_site) {
          
$fileContent='
<Files "*.jpg">
deny from all
</Files> 
<Files "*.JPG">
deny from all
</Files>  
          '
;
          
t3lib_div::writeFile($folderCurrent.'.htaccess',$fileContent);
          
$fileContent='
<Files "*.jpg">
Allow from all
</Files> 
<Files "*.JPG">
Allow from all
</Files> 
          '
;
          foreach (array(
"thumb""small""water") as $value){
               
t3lib_div::mkdir($folderCurrent.$value);
               
t3lib_div::writeFile($folderCurrent.$value.'/.htaccess',$fileContent);
          }
}
     }


}


?>
__________________
Веб-студия ТТЛАБ
www.ttlab.ru
Valery Romanchev вне форума   Ответить с цитированием
Старый 20.08.2007, 00:27   #3
enot
Новенький
 
Регистрация: 02.11.2006
Сообщений: 24
По умолчанию

Спасибо
а почему GD?
я думал imageMagick лучше все операции с картинками выполняет...
и кода меньше писать
у меня вот так получилось

PHP код:
    /**
     * Добавляет watermark на картинку $img
     *
     * @param string $img - файл с картинкой
     * @param string $watermark_file - файл  watermark
     * @return boolean true - если все нормально иначе false
     */
    
function addWatermark($img$watermark_file$disslove 15) {
        
$cmd Pictures::addWatermarkCmd($img,$watermark_file,$disslove);
        if(
$cmd) {
            
exec($cmd);            
            return 
true;
        }
        else {
            return 
false;
        }
    }

    
/**
     * Возвращает команду для ImageMAgick для добавляет watermark на картинку $img
     *
     * @param string $img - файл с картинкой
     * @param string $watermark_file - файл  watermark
     * @return string текст команда
     */
    
function addWatermarkCmd($img$watermark_file$disslove 15) {
        
$data getimagesize($img);
        if(
$data === false) {
            return 
false;
        }
        
        
$W Pictures::resize($watermark_file$data);
        if(
$W === false) {
            return 
false;
        }
        
$params '-dissolve '.$disslove.' -gravity Center "'.$W .'" "'.$img.'"';
        
$cmd t3lib_div::imageMagickCommand('composite'$params' "'.$img.'"');    
        return 
$cmd;                
    } 
enot вне форума   Ответить с цитированием
Старый 03.08.2010, 13:41   #4
margol
Senior Member
 
Аватар для margol
 
Регистрация: 09.07.2007
Адрес: Волгоград
Сообщений: 322
Отправить сообщение для margol с помощью ICQ
По умолчанию

офф-топ, пардон...
__________________
margol вне форума   Ответить с цитированием
Ответ

Опции темы
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB code is Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход

Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
TV: скрыть картинку if no link Tod TypoScript практикум 1 27.03.2007 00:28
Задавать картинку для страницы demav Общие вопросы 6 14.03.2007 01:52
вставить картинку в контент Илья Общие вопросы 0 26.05.2006 16:21
как назначить странице картинку? Илья Общие вопросы 1 29.03.2006 16:34


Часовой пояс GMT +4, время: 14:33.


Работает на vBulletin® версия 3.8.1.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot

Хостинг и техническая поддержка: TYPO3 Лаборатория