Example #1
0
 /**
  * Overlay image
  *
  * Parameter array:
  * 'x': int X-point of overlayed image
  * 'y': int Y-point of overlayed image
  * 'filename': string The filename of the image to overlay
  * 'width': int [optional] The width of the overlayed image (resizing if possible)
  * 'height': int [optional] The height of the overlayed image (resizing if possible)
  * 'alignment': array [optional] Alignment
  */
 function image($params)
 {
     if (isset($this->_imageMap)) {
         $this->_imageMap->image($params);
     }
     parent::image($params);
 }
Example #2
0
 /**
  * Overlay image
  *
  * Parameter array:
  * 'x': int X-point of overlayed image
  * 'y': int Y-point of overlayed image
  * 'filename': string The filename of the image to overlay
  * 'width': int [optional] The width of the overlayed image (resizing if possible)
  * 'height': int [optional] The height of the overlayed image (resizing if possible)
  * 'alignment': array [optional] Alignment
  */
 function image($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $filename = $params['filename'];
     list($width, $height, $type, $attr) = getimagesize($filename);
     $width = isset($params['width']) ? $params['width'] : $width;
     $height = isset($params['height']) ? $params['height'] : $height;
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     $file = fopen($filename, 'rb');
     $filedata = fread($file, filesize($filename));
     fclose($file);
     $data = 'data:' . image_type_to_mime_type($type) . ';base64,' . base64_encode($filedata);
     $this->_addElement('<image xlink:href="' . $data . '" x="' . $x . '" y="' . $y . '"' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' preserveAspectRatio="none"/>', $params);
     parent::image($params);
 }
Example #3
0
 /**
  * Overlay image
  *
  * Parameter array:
  * 'x': int X-point of overlayed image
  * 'y': int Y-point of overlayed image
  * 'filename': string The filename of the image to overlay
  * 'width': int [optional] The width of the overlayed image (resizing if possible)
  * 'height': int [optional] The height of the overlayed image (resizing if possible)
  * 'alignment': array [optional] Alignment
  */
 function image($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $filename = $params['filename'];
     $width = isset($params['width']) ? $params['width'] : false;
     $height = isset($params['height']) ? $params['height'] : false;
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     if (substr($filename, -4) == '.png') {
         $type = 'png';
     } elseif (substr($filename, -4) == '.jpg') {
         $type = 'jpeg';
     }
     $image = pdf_load_image($this->_pdf, $type, realpath($filename), '');
     $width_ = pdf_get_value($this->_pdf, 'imagewidth', $image);
     $height_ = pdf_get_value($this->_pdf, 'imageheight', $image);
     $outputWidth = $width !== false ? $width : $width_;
     $outputHeight = $height !== false ? $height : $height_;
     if (!is_array($alignment)) {
         $alignment = array('vertical' => 'top', 'horizontal' => 'left');
     }
     if (!isset($alignment['vertical'])) {
         $alignment['vertical'] = 'top';
     }
     if (!isset($alignment['horizontal'])) {
         $alignment['horizontal'] = 'left';
     }
     if ($alignment['horizontal'] == 'right') {
         $x -= $outputWidth;
     } elseif ($alignment['horizontal'] == 'center') {
         $x -= $outputWidth / 2;
     }
     if ($alignment['vertical'] == 'top') {
         $y += $outputHeight;
     } elseif ($alignment['vertical'] == 'center') {
         $y += $outputHeight / 2;
     }
     if ($width === false && $height === false) {
         $scale = 1;
     } else {
         $scale = max($height / $height_, $width / $width_);
     }
     pdf_place_image($this->_pdf, $image, $this->_getX($x), $this->_getY($y), $scale);
     pdf_close_image($this->_pdf, $image);
     parent::image($params);
 }
Example #4
0
File: SWF.php Project: roojs/pear
 /**
  * Overlay image
  *
  * Parameter array:
  * 'x'         : int X-point of overlayed image
  * 'y'         : int Y-point of overlayed image
  * 'filename'  : string The filename of the image to overlay
  * 'width'     : int [optional] The width of the overlayed image (resizing if possible)
  * 'height'    : int [optional] The height of the overlayed image (resizing if possible)
  * 'alignment' : array [optional] Alignment
  * 'url'       : string [optional] Target URL
  *
  * @param array $params Parameter array
  *
  * @return void
  */
 function image($params)
 {
     parent::image($params);
 }