-
این راهی که tasnim68 گفته کاملا درسته
حالا اگه سايز عکس از 200*150 کمتر باشه چی ميشه؟عکس بزرگ ميشه؟
حالا اگه عکس دراز باشه؟ یا مربع باشه؟
بهترين راه حفظ نسبت طول و عرض عکس در موقع کوچيک کردنشه
مثال خود php:
[ برای مشاهده لینک ، با نام کاربری خود وارد شوید یا ثبت نام کنید ]
Example #2 Resampling an image proportionally
[php]
<?php
// The file
$filename = 'test.jpg';
// Set a maximum height and width
$width = 200;
$height = 200;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, null, 100);
?>
[/php]