<?php
function make_image($type=0, $width, $height) {
if($type == 0) {
$image = imagecreatetruecolor($width, $height);
}
elseif($type == 1) {
$image = imagecreate($width, $height);
}
return $image;
}
function make_from_image($type, $path) {
if($type == 0) {
$image = imagecreatefromjpeg($path);
}
elseif($type == 1) {
$image = imagecreatefromgif($path);
}
elseif($type == 2) {
$image = imagecreatefrompng($path);
}
return $image;
}
function make_color($image, $r, $v, $b) {
$val = imagecolorallocate($image, $r,$v,$b);
return $val;
}
function make_ellipse($image, $centre_x, $centre_y, $largeur,
$hauteur, $color) {
$val = imagefilledellipse($image, $centre_x, $centre_y,
$largeur, $hauteur, $color);
return $val;
}
function make_rectangle($image, $x, $y, $x2, $y2, $color) {
$val = imagefilledrectangle($image, $x, $y, $x2,
$y2, $color);
return $val;
}
function make_polygone($image, $values, $points, $color) {
$val = imagefilledpolygon($image, $values, $points,
$color);
return $val;
}
function make_txt(
$type, $image, $x, $y, $txt, $font, $color) {
if($type == 0) {
$val = imagestring($image, $font, $x, $y, $txt, $color);
}
elseif($type == 1) {
$val = imagestringup($image, $font, $x, $y, $txt, $color);
}
return $val;
}
function resize($dest, $image, $pourcentage) {
$size = getImageSize($dest);
$new_width = $size[0] * $pourcentage;
$new_height = $size[1] * $pourcentage;
$ext = strrchr($dest,".");
$dst_img = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($dst_img, $image, 0, 0, 0, 0,
$new_width, $new_height, $size[0], $size[1]);
imagejpeg($dst_img, $dest, 100);
return $dest;
}
function save_image($image, $path, $nom, $type, $qualite='') {
$dest = $path . $nom;
$quality = (strlen($qualite) > 0 ? $qualite : 100);
switch($type) {
case"jpg":
case"jpeg":
$dest .= '.' . $type;
imagejpeg($image, $dest, $quality);
break;
case"gif":
$dest .= '.' . $type;
imagegif($image, $dest);
break;
case"png":
$dest .= '.' . $type;
imagepng($image, $dest);
break;
}
return $dest;
}
function detruire($image) {
imagedestroy($image);
}
function make_permission($path) {
if(file_exists($path) {
$perms = fileperms($path);
if($perms != 0777) {
$val = chmod($path, 0777);
}
}
else {
$val = false;
}
return $val;
}
function effacer($path) {
if (make_permission($path)) {
if(!efface($path)){
echo "<SCRIPT>alert(\"Erreur lors de la suppression de
l’image\");</SCRIPT>";
}
else {
echo "<SCRIPT>
alert(\"Image correctement effacée\");</SCRIPT>";
}
}
}
?>
|
|