1: <?php
2:
3: /**
4: * Pry Framework
5: *
6: * LICENSE
7: *
8: * This source file is subject to the new BSD license that is bundled
9: * with this package in the file LICENSE.txt.
10: *
11: */
12:
13: namespace Pry\Image;
14:
15: /**
16: * Convertisseur de type d'image
17: * @category Pry
18: * @package Image
19: * @version 1.1.0
20: * @author Olivier ROGER <oroger.fr>
21: *
22: */
23: class Converter extends Image
24: {
25:
26: /**
27: * Nouvelle image créer
28: *
29: * @var ressource
30: */
31: private $newimg;
32:
33: /**
34: * Constructeur
35: *
36: * @param image $image Flux ou fichier
37: */
38: public function __construct($img)
39: {
40: $info = getimagesize($img);
41: $this->width = $info[0];
42: $this->height = $info[1];
43: $this->type = $info[2]; // 1:gif; 2:jpg; 3:png; 4:swf; 5:psd; 6:bmp; 7:tiff
44: $this->copie = null;
45: $this->source = $this->createFromType($img);
46: $this->type = $typeOut;
47: }
48:
49: /**
50: * Convertion de l'image de base dans le type choisi
51: *
52: * @param int $typeOut Type de sortie
53: */
54: public function convert($typeOut)
55: {
56: $this->type = $typeOut;
57: $this->newimg = imagecreatetruecolor($this->width, $this->height);
58: imagecopy($this->newimg, $this->source, 0, 0, 0, 0, $this->width, $this->height);
59: $this->source = $this->newimg;
60: }
61:
62: }
63:
64: ?>