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: * Convertisseur de type d'image
15: * @category Pry
16: * @package Image
17: * @version 1.1.0
18: * @author Olivier ROGER <oroger.fr>
19: *
20: */
21: class Image_Converter extends Image_Image
22: {
23: /**
24: * Nouvelle image créer
25: *
26: * @var ressource
27: */
28: private $newimg;
29:
30: /**
31: * Constructeur
32: *
33: * @param image $image Flux ou fichier
34: */
35: public function __construct($img)
36: {
37: $info = getimagesize($img);
38: $this->width = $info[0];
39: $this->height = $info[1];
40: $this->type = $info[2]; // 1:gif; 2:jpg; 3:png; 4:swf; 5:psd; 6:bmp; 7:tiff
41: $this->copie = null;
42: $this->source = $this->createFromType($img);
43: $this->type = $typeOut;
44: }
45:
46: /**
47: * Convertion de l'image de base dans le type choisi
48: *
49: * @param int $typeOut Type de sortie
50: */
51: public function convert($typeOut)
52: {
53: $this->type = $typeOut;
54: $this->newimg = imagecreatetruecolor($this->width,$this->height);
55: imagecopy($this->newimg,$this->source,0,0,0,0,$this->width,$this->height);
56: $this->source = $this->newimg;
57: }
58: }
59: ?>