mipmip
2/14/2012 - 9:05 PM

TYPO3: Using GIFBUILDER from PHP

TYPO3: Using GIFBUILDER from PHP

<?php
// Using GIFBUILDER from PHP

//Example of creating an image from scratch with text with some extra options

$conf = array(
   'file' => 'GIFBUILDER',
   'file.' => array(
      'XY' => '177,212',
      'backColor' => '#cecece',
      '10' => 'TEXT',
      '10.' => array(
         'fontColor' => 'red',
         'niceText' => '1',
         'fontSize' => '20',
         'offset' => '20,40',
         'text' => 'No',
         'fontFile' => 't3lib/fonts/vera.ttf'
      ),
      '20' => 'TEXT',
      '20.' => array(
         'fontColor' => 'red',
         'niceText' => '1',
         'fontSize' => '20',
         'offset' => '20,80',
         'text' => 'preview',
         'fontFile' => 't3lib/fonts/nimbus.ttf'
      )
   ),
);
 
$preview = $this->pobj->cObj->IMG_RESOURCE($conf);



// Example of resizing an image

$prvimg='uploads/tx_p3ga/'.$row['tx_p3ga_preview_image_manual'];
if(is_file($prvimg))
{
   $conf = array(
      'file' => $prvimg,
      'file.' => array(
         'maxW' => '177',
         'maxH' => '212'
      ),
   );
   $preview = $this->pobj->cObj->IMG_RESOURCE($conf);
}
// 
$conf = array(
   'file' => 'GIFBUILDER',
   'file.' => array(
      'XY' => '177,212',
      'backColor' => '#cecece',
      '10' => 'TEXT',
      '10.' => array(
         'fontColor' => 'red',
         'niceText' => '1',
         'fontSize' => '20',
         'offset' => '20,40',
         'text' => 'No',
         'fontFile' => 't3lib/fonts/vera.ttf'
      ),
      '20' => 'TEXT',
      '20.' => array(
         'fontColor' => 'red',
         'niceText' => '1',
         'fontSize' => '20',
         'offset' => '20,80',
         'text' => 'preview',
         'fontFile' => 't3lib/fonts/nimbus.ttf'
      )
   ),
);
 
$preview = $this->pobj->cObj->IMG_RESOURCE($conf);
Example of resizing an image

$prvimg='uploads/tx_p3ga/'.$row['tx_p3ga_preview_image_manual'];
if(is_file($prvimg))
{
   $conf = array(
      'file' => $prvimg,
      'file.' => array(
         'maxW' => '177',
         'maxH' => '212'
      ),
   );
   $preview = $this->pobj->cObj->IMG_RESOURCE($conf);
}

?>