[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Image/Canvas/GD/ -> JPG.php (source)

   1  <?php
   2  
   3  /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
   4  
   5  /**
   6   * Image_Canvas
   7   *
   8   * Canvas class to handle JPEG format.
   9   *
  10   * PHP versions 4 and 5
  11   *
  12   * LICENSE: This library is free software; you can redistribute it and/or modify
  13   * it under the terms of the GNU Lesser General Public License as published by
  14   * the Free Software Foundation; either version 2.1 of the License, or (at your
  15   * option) any later version. This library is distributed in the hope that it
  16   * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  17   * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  18   * General Public License for more details. You should have received a copy of
  19   * the GNU Lesser General Public License along with this library; if not, write
  20   * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  21   * 02111-1307 USA
  22   *
  23   * @category   Images
  24   * @package    Image_Canvas
  25   * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  26   * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  27   * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  28   * @version    CVS: $Id: JPG.php,v 1.2 2005/08/24 20:37:34 nosey Exp $
  29   * @link       http://pear.php.net/pepr/pepr-proposal-show.php?id=212
  30   */
  31  
  32  /**
  33   * Include file Image/Canvas/GD.php
  34   */
  35  require_once  'Image/Canvas/GD.php';
  36  
  37  /**
  38   * JPEG Canvas class.
  39   * 
  40   * @category   Images
  41   * @package    Image_Canvas
  42   * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  43   * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  44   * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  45   * @version    Release: @package_version@
  46   * @link       http://pear.php.net/pepr/pepr-proposal-show.php?id=212
  47   */
  48  class Image_Canvas_GD_JPG extends Image_Canvas_GD
  49  {
  50      
  51      /**
  52       * The JPEG quality
  53       * @var int
  54       * @access private
  55       */
  56      var $_quality = 75;
  57      
  58      /**
  59       * Create the JPEG canvas
  60       * 
  61       * Additional parameters other than those available for common {@link
  62       * Image_Graph_Canvas_GD} class are:
  63       * 
  64       * 'quality' The JPEG quality in as a percentage value from 0 (lowest
  65       * quality, smallest file) to 100 (highest quality, biggest file)
  66       *
  67       * @param array $param Parameter array
  68       */
  69      function Image_Canvas_GD_JPG($param)
  70      {
  71          parent::Image_Canvas_GD($param);
  72          
  73          if (isset($param['quality'])) {
  74              $this->_quality = max(0, min(100, $param['quality']));
  75          } 
  76  
  77          $this->rectangle(
  78                  array(
  79                      'x0' => $this->_left,
  80                      'y0' => $this->_top,
  81                      'x1' => $this->_left + $this->_width - 1,
  82                      'y1' => $this->_top + $this->_height - 1,
  83                      'fill' => 'white',
  84                      'line' => 'transparent'
  85                  )
  86              );
  87      }
  88  
  89      /**
  90       * Output the result of the canvas
  91       *
  92       * @param array $param Parameter array
  93       * @abstract
  94       */
  95      function show($param = false)
  96      {
  97          parent::show($param);
  98          header('Content-type: image/jpg');
  99          header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"');
 100          ImageJPEG($this->_canvas, '', $this->_quality);
 101          ImageDestroy($this->_canvas);
 102      }
 103  
 104      /**
 105       * Output the result of the canvas
 106       *
 107       * @param array $param Parameter array
 108       * @abstract
 109       */
 110      function save($param = false)
 111      {
 112          parent::save($param);
 113          ImageJPEG($this->_canvas, $param['filename'], $this->_quality);
 114          ImageDestroy($this->_canvas);
 115      }
 116  
 117  }
 118  
 119  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7