Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

  • Image_Captcha
  • Image_Converter
  • Image_DegradeCouleur
  • Image_Font
  • Image_Gauge
  • Image_Image
  • Image_Traitement

Exceptions

  • Image_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Pry Framework
  4:  *
  5:  * LICENSE
  6:  *
  7:  * This source file is subject to the new BSD license that is bundled
  8:  * with this package in the file LICENSE.txt.
  9:  * 
 10:  * @version $Revision: 276 $
 11:  */
 12: 
 13: /**
 14:  * Application d'effet sur une image
 15:  * 
 16:  * @category Pry
 17:  * @package Image
 18:  * @version 1.0.0 
 19:  * @author Olivier ROGER <oroger.fr>
 20:  */
 21: class Image_Traitement
 22: {
 23:     /**
 24:      * Objet représentant l'image
 25:      *
 26:      * @var Image_Image
 27:      */
 28:     private $objet;
 29:     
 30:     /**
 31:      * Ressource de l'image à modifier
 32:      *
 33:      * @var ressource
 34:      */
 35:     private $sourceImage;
 36:     
 37:     /**
 38:      * Dimension X de l'image
 39:      *
 40:      * @var int
 41:      */
 42:     private $largeur;
 43:     
 44:     /**
 45:      * Dimension Y de l'image
 46:      *
 47:      * @var int
 48:      */
 49:     private $hauteur;
 50:     
 51:     /**
 52:      * Constructeur
 53:      * 
 54:      * @param Image_Image $img Objet de l'image
 55:      */
 56:     public function __construct(Image_Image &$img)
 57:     {
 58:         if(!is_object($img)){
 59:             throw new Image_Exception('Objet attendu');
 60:         }
 61:         
 62:         $this->objet = $img;
 63:         $this->sourceImage = $this->objet->getSource();
 64:         $data = $this->objet->getInfo();
 65:         $this->largeur = $data['width'];
 66:         $this->hauteur = $data['height'];
 67:     }
 68:     
 69:     /**
 70:      * Convertit l'image en niveau de gris. Imagefilter remplace les calcul via matrice. 10x plus rapide
 71:      * @access public
 72:      */
 73:     public function greyScale()
 74:     {
 75:         if(imagefilter($this->sourceImage,IMG_FILTER_GRAYSCALE))
 76:             $this->objet->setSource($this->sourceImage);
 77:     }
 78:     
 79:     /**
 80:      * Ajoute du flou à l'image. Imagefilter remplace les calcul via matrice. 10x plus rapide
 81:      * @access public
 82:      * @param int $factor Facteur de flou
 83:      */
 84:     public function blur($factor)
 85:     {
 86:         if(imagefilter($this->sourceImage,IMG_FILTER_GAUSSIAN_BLUR,$factor))
 87:             $this->objet->setSource($this->sourceImage);
 88:     }
 89:     
 90:     /**
 91:      * Ajoute du bruit à l'image. (relativement long a executer puisque traitement px par px)
 92:      * @access public
 93:      * @param int $factor paramètre de bruit (0-255)
 94:      * 
 95:      */
 96:     public function addNoise($factor)
 97:     {   
 98:         for($x=0;$x<$this->largeur;$x++)
 99:         {
100:             for($y=0;$y<$this->hauteur;$y++)
101:             {
102:                 $rand = mt_rand(-$factor,$factor);
103:                 $rgb = imagecolorat($this->sourceImage,$x,$y);
104:                 $r   = (($rgb>>16)& 0xFF)+$rand;
105:                 $g   = (($rgb>>8)& 0xFF)+$rand;
106:                 $b   = ($rgb & 0xFF)+$rand;
107:                             
108:                 $color = imagecolorallocate($this->sourceImage,$r,$g,$b);
109:                 imagesetpixel($this->sourceImage,$x,$y,$color);
110:             }
111:         }
112:         $this->objet->setSource($this->sourceImage);
113:     }
114:      
115:      /**
116:       * Netteté
117:       * @access public
118:       */
119:      public function sharppen()
120:      {
121:         if(imagefilter($this->sourceImage,IMG_FILTER_MEAN_REMOVAL))
122:             $this->objet->setSource($this->sourceImage);
123:      }
124:      
125:     /**
126:      * Modifie le contraste de l'image. Imagefilter remplace les calcul via matrice. 10x plus rapide
127:      * @access public
128:      * @param int $factor Facteur de flou
129:      */
130:      public function contrast($factor)
131:      {
132:         if(imagefilter($this->sourceImage,IMG_FILTER_CONTRAST,$factor))
133:             $this->objet->setSource($this->sourceImage);
134:      }
135:       
136:      /**
137:      * Modifie la luminosité. Imagefilter remplace les calcul via matrice. 10x plus rapide
138:      * @access private
139:      * @param int $factor Facteur de flou
140:      */
141:      public function brightness($factor)
142:      {
143:         if(imagefilter($this->sourceImage,IMG_FILTER_BRIGHTNESS,$factor))
144:             $this->objet->setSource($this->sourceImage);
145:      }
146: }
147:  ?>
Pry Framework API documentation generated by ApiGen 2.6.1