- <?php
- # begin-configuration
- $maxWidth = 200;
- $maxHeight = 200;
- # end-configuration
-
- header("Content-Type: image/jpeg");
- // amelioration de detection de l'extention par Bricomix
- $ext = strtolower(substr($pic, strrpos($pic, '.') + 1));
- switch($ext) {
- case "jpg":
- case "jpeg":
- $img_in = imagecreatefromjpeg($pic);
- break;
- case "gif":
- $img_in = imagecreatefromgif($pic);
- break;
- case "png":
- $img_in = imagecreatefrompng($pic);
- break;
- default:
-
- }
- list($width, $height, $type, $attr) = getimagesize($pic);
- if (empty($noresize)) {
- $ratio = $width/$height;
- if ($ratio>=0) {
- $nw = $maxWidth;
- $nh = $maxHeight/$ratio;
- } else {
- $nw = $maxWidth/$ratio;
- $nh = $maxHeight;
- }
- } else {
- $nw = $width;
- $nh = $height;
- }
- $img_out = imagecreatetruecolor($nw, $nh);
- imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in));
-
- $t = imagejpeg($img_out);
- echo $t;
-
- ?>
<?php
# begin-configuration
$maxWidth = 200;
$maxHeight = 200;
# end-configuration
header("Content-Type: image/jpeg");
// amelioration de detection de l'extention par Bricomix
$ext = strtolower(substr($pic, strrpos($pic, '.') + 1));
switch($ext) {
case "jpg":
case "jpeg":
$img_in = imagecreatefromjpeg($pic);
break;
case "gif":
$img_in = imagecreatefromgif($pic);
break;
case "png":
$img_in = imagecreatefrompng($pic);
break;
default:
}
list($width, $height, $type, $attr) = getimagesize($pic);
if (empty($noresize)) {
$ratio = $width/$height;
if ($ratio>=0) {
$nw = $maxWidth;
$nh = $maxHeight/$ratio;
} else {
$nw = $maxWidth/$ratio;
$nh = $maxHeight;
}
} else {
$nw = $width;
$nh = $height;
}
$img_out = imagecreatetruecolor($nw, $nh);
imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in));
$t = imagejpeg($img_out);
echo $t;
?>