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
| private function insertImage($image, $image_element, $image_element_pos_x, $image_element_pos_y, $image_element_transparency) {
if (!file_exists($this->MeganeISG_Config->ConfigElementsDir.$image_element)) {
throw new Exception('Impossible d\'insérer l\'image <strong>'.$image_element.'</strong> : le fichier n\'existe pas.');
}
$image_element_ext = pathinfo($image_element);
$image_element_ext = $image_element_ext['extension'];
switch ($image_element_ext) {
case 'png':
$element_image = imagecreatefrompng($this->MeganeISG_Config->ConfigElementsDir.$image_element);
break;
case 'jpg':
$element_image = imagecreatefromjpeg($this->MeganeISG_Config->ConfigElementsDir.$image_element);
break;
default:
throw new Exception('Extension de fichier inconnue : <strong>'.$image_element_ext.'</strong>.');
break;
}
$width = imagesx($element_image);
$height = imagesy($element_image);
if (!imagecopymerge($image, $element_image, (int)$image_element_pos_x, (int)$image_element_pos_y, 0, 0, $width, $height, (int)$image_element_transparency)) {
throw new Exception('Impossible d\'insérer l\'image <strong>'.$image_element.'</strong>: erreur GD.</strong>');
}
} |
Partager