За последние 24 часа нас посетили 15709 программистов и 1543 робота. Сейчас ищут 967 программистов ...

Имя созданого изображения

Тема в разделе "Вопросы от блондинок", создана пользователем OldEr, 7 янв 2008.

  1. S.t.A.M.

    S.t.A.M. Активный пользователь

    С нами с:
    10 сен 2007
    Сообщения:
    1.041
    Симпатии:
    0
    Вот функция из моего движка, бери изучай!
    Все что ты запрашивал делает.

    PHP:
    1. function resize_image($fileS,$fileD,$size_x=0,$size_y=0,$quality=65)
    2. {
    3.     $uploadedfile = $fileS;
    4.     ini_set("memory_limit", "64M");
    5.  
    6.     //Create an Image from it so we can do the resize
    7.     $src = imagecreatefromjpeg($uploadedfile);
    8.  
    9.     // Capture the original size of the uploaded image
    10.     list($width,$height)=getimagesize($uploadedfile);
    11.  
    12.     if (($size_x>0) && ($size_y==0)) {
    13.         $newwidth=$size_x;
    14.         $newheight= $height*($size_x/$width);
    15.     }
    16.  
    17.     if (($size_x==0) && ($size_y>0)) {
    18.         $newheight= $size_y;
    19.         $newwidth= $width*($size_y/$height);
    20.     }
    21.  
    22.     if (($size_x>0) && ($size_y>0)) {
    23.         $newwidth=$size_x;
    24.         $newheight= $height*($size_x/$width);
    25.         if ($newheight>$size_y) {           $newheight= $size_y;
    26.             $newwidth= $width*($size_y/$height);
    27.         }
    28.     }
    29.  
    30.     if (($size_x==0) && ($size_y==0)) {
    31.         $newheight= 120;
    32.         $newwidth= $width*(120/$height);
    33.     }
    34.  
    35.     $tmp=imagecreatetruecolor($newwidth,$newheight);
    36.     imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
    37.     $filename = $fileD;
    38.     imagejpeg($tmp,$filename,$quality);
    39.     imagedestroy($src);
    40.     imagedestroy($tmp);
    41. }
     
  2. OldEr

    OldEr Активный пользователь

    С нами с:
    7 янв 2008
    Сообщения:
    17
    Симпатии:
    0
    S.t.A.M., спасибо, буду пробовать)