* Le fichier est a inclure dans votre script avec l'instruction includePackage(upload.php) *@package package *@subpackage file */ class ImageUploadToDir extends UploadToDir { /**#@+ *@access private */ /**#@-*/ /** * makeThumbs actuellement la methode n'est prevue que pour la creation de thumbs lors de l'upload de l'image... *@access public *@param integer largeur max *@param integer hauteur max *@return booleen */ function makeThumbs($key, $path, $longest_side = 120) { $prefixe=(!defined("DATA_ACCES_TABLE_PREFIX"))?"": DATA_ACCES_TABLE_PREFIX ; # code de creation de la thumbs -> recuperation du path du fichier... $finalPath = $GLOBALS["CONF_DATA_PATH"]."data/upload/thumbs/thumbs-".$key."-".$longest_side.".png"; if (file_exists($path)) { switch (strtolower($this->extentionFinder($path))) { case "png": { $im = imagecreatefrompng($path); break; } case "jpg": case "pjpeg": case "jpeg": case "jpe": { $im = imagecreatefromjpeg($path); break; } case "gif": { $im = imagecreatefromgif($path); break; } default: { return false; } } // some smart sizing list($img_w, $img_h) = getimagesize($path); if ($img_w > $img_h) { // longest side is width: use that to calc thumb size $thumb_w = $longest_side; $thumb_h = (int)($longest_side * ($img_h / $img_w)); } else { // longest side is height: use that to calc thumb size $thumb_h = $longest_side; $thumb_w = (int)($longest_side * ($img_w / $img_h)); } $tim = imagecreatetruecolor($thumb_w, $thumb_h); imagecopyresized($tim, $im, 0, 0, 0, 0, $thumb_w, $thumb_h, $img_w, $img_h); imagepng($tim, $finalPath); imagedestroy($im); imagedestroy($tim); return true; } else { $systemError=3; $classe="Image"; $message="Chemin d'image incorrect"; addError($systemError,$classe,$message, __line__, __file__); return false; //die(); } } } ?>