كد پايين رو در صفحه اي با نام thumb.php قرار بده.نقل قول:
مثلا سایز اصلی عکس هست : 800 * 600 ولی تو صفحه 100 * 100 نشون داده میشه این هم بده 100 * 100 رو ذخیره کنه
تشکر//
[PHP]<?php
$filename = $_GET['url'];
$type=substr($filename,-4);
if($type=='.gif'){
// Content type
header('Content-type: image/gif');
// Get new sizes
list($width, $height) = getimagesize($filename);
if($height>100){
$new_height = '100' ;
$new_width = $width / ($height/$new_height);
}else{
$new_height=$height;
$new_width=$width;
}
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromgif($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagegif($image_p, null, 100);
}
if($type=='.png'){
// Content type
header('Content-type: image/png');
// Get new sizes
list($width, $height) = getimagesize($filename);
if($height>100){
$new_height = '100' ;
$new_width = $width / ($height/$new_height);
}else{
$new_height=$height;
$new_width=$width;
}
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefrompng($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagepng($image_p, null);
}
if(($type=='.jpg')OR($type=='.jpeg')){
// Content type
header('Content-type: image/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filename);
if($height>100){
$new_height = '100' ;
$new_width = $width / ($height/$new_height);
}else{
$new_height=$height;
$new_width=$width;
}
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagejpeg($image_p, null, 100);
}
?>
[/PHP]
بعد هر عكسي رو كه خواستي كوچك نشون بدي آدرس عكس رو به جاي نوشته قرمز بذار.
اين رو براي يه برنامه ديگه نوشته بودم ولي گفتي عجله داري برات گذاشتم.خودم هم الان عجله دارم(سه در چهار شروع شده) بعدا اگه مشكلي بود بگو برطرف كنم.کد:domain.com/thumb.php?url=adreseaks