
26-03-2009, 20:30
|
|
|
|
חבר מתאריך: 06.06.07
הודעות: 749
|
|
|
תמונה לא פרופורציונלית
מה המצב
מעוניין לדעת מדוע התמונה לא מוקטנת בצורה פרופורציונלית
זה מה שאני שולח
קוד PHP:
$picsize = getimagesize($_FILES['myfile']['tmp_name']); if(move_uploaded_file($_FILES['myfile']['tmp_name'], '../../' . $dir . $_FILES['myfile']['name'])) { $picsrc = $dir.$_FILES['myfile']['name']; $picnewsrc = $dir.'smallpicture/'.$_FILES['myfile']['name']; $newwidth = '145'; $w = $picsize[0]; $h = $picsize[1]; $newhight = $h * ($newwidth / $w); ImageResize($picsrc,$newwidth,$newhight,$picnewsrc );
זה הקוד
קוד PHP:
function ImageResize($src,$width,$height,$output) { $info = explode(".",$src); $ext = strtolower($info[1]); if($ext == "jpeg" || $ext == "jpg" || $ext == "JPG" || $ext == "JPEG") { $source_image = imagecreatefromjpeg('../../'.$src); } elseif($ext == "gif" || $ext == "GIF") { $source_image = imagecreatefromgif('../../'.$src); } else { die("Unknown image file type. (know only jpeg,jpg,gif) Filename supplied: $src"); } $filesize = (list($awidth,$aheight) = getimagesize('../../'.$src)); $output_image = imagecreatetruecolor ($width, $height); imagecopyresampled ($output_image, $source_image, 0,0,0,0, $width, $height, $awidth, $aheight); if($ext == "jpeg" || $ext == "jpg" || $ext == "JPG" || $ext == "JPEG") { imagejpeg($output_image,'../../'.$output,100); } else if ($ext == "gif" || $ext == "GIF") { imagegif($output_image,$output,100); } imagedestroy ($source_image); imagedestroy ($output_image); }
תודה
|