העלאת תמונה ושינוי גודל

CJ STONE

New member
העלאת תמונה ושינוי גודל../images/Emo53.gif

חבר'ה איזה סקריפט אתם משתמשים בכדי להעלות תמונה ולשנות לה את הגודל? מישהו פה משתמש ב CLASS מוכן ויכול להמליץ על משהו?
 

Macpire

New member
אני משתמש בפונקציה פשוטה של gl

function createthumb($name,$filename,$new_w,$new_h) { $system=explode(".",$name); if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);} if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);} if (preg_match("/gif/",$system[1])){$src_img=imagecreatefromgif($name);} $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($new_w > $old_x) { $thumb_w=$old_x; $thumb_h=$old_y; } else { if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); // $thumb_w=$old_x*($new_w/$old_y); // $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if (preg_match("/png/",$system[1])) { imagepng($dst_img,$filename); } if (preg_match("/jpg|jpeg/",$system[1])) { imagejpeg($dst_img,$filename); } if (preg_match("/gif/",$system[1])) { imagegif($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); }​
הקריאה אצלי..
if ($file_type_1=="jpg" or $file_type_1=="png" or $file_type_1=="gif"){ createthumb('upload_dir/'.$this_id.'a_'.$forum.'.'.$file_type_1,'upload_dir/thumbs/'.$this_id.'a_'.$forum.'.'.$file_type_1,150,150); }​
 
למעלה