1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <?php
/*
Classe de gestion des images
Auteur : dig^^
*/
class dgImage
{
var $img;
var $source;
function __construct($url)
{
$this->img = $url;
$this->source = imagecreatefrompng($url);
}
function resize($w, $h, $url)
{
$mini = imagecreatetruecolor($w, $h);
$w_source = imagesx($this->source);
$h_source = imagesy($this->source);
if(!@imagecopyresampled($mini, $this->source, 0, 0, 0, 0, $w, $h, $w_source, $h_source)) throw new Exception('Impossible de créer une miniature de l\'image "'.$this->img.'"');
if(!imagepng($mini, $url)) throw new Exception('Impossible d\'enregistrer la miniature ici : "'.$url.'"');
}
}
?> |
Partager