function creer_miniature($img_big, $dirSrc, $dirDest, $hauteur_miniatures) { $tnH = $hauteur_miniatures; $t_rename = 0; $th_quality = 1; $img_big = $dirSrc . "/" . $img_big; $size = @getimagesize($img_big); switch($size[2]){ case 1: if (imagetypes() & IMG_GIF) $src = imagecreatefromgif($img_big); break; case 2: if (imagetypes() & IMG_JPG) $src = imagecreatefromjpeg($img_big); break; case 3: if (imagetypes() & IMG_PNG) $src = imagecreatefrompng($img_big); break; default : if (preg_match("/\.wbmp$/",$img_big) && (imagetypes() & IMG_WBMP)){ $src = imagecreatefromwbmp($img_big); $size[0] = imagesx($src); $size[1] = imagesy($src); if (!isset($format)) $format = 4; } } if (!$src){ $thumbs[$img_big] = "Format NON SUPPORTE !"; }else{ $destW = $size[0]*$tnH/$size[1]; $destH = $tnH; if ($th_quality == 1){ $dest = imagecreatetruecolor($destW,$destH); imagecopyresampled($dest,$src,0,0,0,0,$destW,$destH,$size[0],$size[1]); } else { $dest = imagecreatetruecolor($destW,$destH); imagecopyresized($dest,$src,0,0,0,0,$destW,$destH,$size[0],$size[1]); } $tn_name = $img_big; $tn_name = preg_replace("/\.(gif|jpe|jpg|jpeg|png|wbmp)$/i","",$tn_name); $tn_name = preg_replace("/.*\/([^\/]+)$/i","$dirDest\\1",$tn_name); if (isset($format)) $type = $format; else $type = $size[2]; switch($type){ case 1 : if (imagetypes() & IMG_GIF){ imagegif($dest,$tn_name.".gif"); $thumbs[$img_big] = "$tn_name.gif"; } break; case 2: if (imagetypes() & IMG_JPG){ imagejpeg($dest,$tn_name.".jpg"); $thumbs[$img_big] = "$tn_name.jpg"; } break; case 3: if (imagetypes() & IMG_PNG){ imagepng($dest,$tn_name.".png"); $thumbs[$img_big] = "$tn_name.png"; } break; default: if (imagetypes() & IMG_WBMP){ imagewbmp($dest,$tn_name.".wbmp"); $thumbs[$img_big] = "$tn_name.wbmp"; } } if (!($thumbs[$img_big])){ $thumbs[$img_big] = "Format NON SUPPORTE !"; } // FIN CREATION MINIATURE } } ?>
|