• 27-06-2009, 14:53:09
    #1
    merhaba arkadaşlar, elimde bir resim galerisi script'i var. upload ve gösterme işlemleri sorunsuz çalışıyor ancak ben istiyorumki resimleri upload ederken standart 640*480 boyutlarına getirsin. imageresize yerleri var içinde ama hangilerini değiştirmem gerektiğini tam olarak çözemedim. width, height, modwidth, modheight değerlerini falan değiştirdim ama direk orjinal boyutunu alıp kaydediyor. ben mi beceremedim yoksa başka bir numarası mı vardır bunun? upload eden kod aşağıdaki gibi;

    	  $imagename = $_FILES['new_image']['name'];
    	  $source = $_FILES['new_image']['tmp_name'];
    	  $target = "../js_slideshow/photos/01/".$imagename;
    	  move_uploaded_file($source, $target);
    	  $imagepath = $imagename;
    	  $save = "../js_slideshow/photos/kucuk/" . $imagepath; //kaydedilen dosya
    	  $file = "../js_slideshow/photos/01/" . $imagepath; //orjinal dosya
    	 if(!empty($imagepath))
    	 {
    	  list($width, $height) = getimagesize($file) ; 
    	  $modwidth = 150; 
    	  $diff = $width / $modwidth;
    	  $modheight = $height / $diff; 
    	  $tn = imagecreatetruecolor($modwidth, $modheight) ; 
    	  $image = imagecreatefromjpeg($file) ; 
    	  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    	  imagejpeg($tn, $save, 100) ; 
    	  $save = "../js_slideshow/photos/kucuk/" . $imagepath; //kaydedilen dosya
    	  $file = "../js_slideshow/photos/01/" . $imagepath; //orjinal dosya
    	  list($width, $height) = getimagesize($file) ; 
    	  $modwidth = 80; 
    	  $diff = $width / $modwidth;
    	  $modheight = $height / $diff; 
    	  $tn = imagecreatetruecolor($modwidth, $modheight) ; 
    	  $image = imagecreatefromjpeg($file) ; 
    	  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    	 imagejpeg($tn, $save, 100) ;
    konu htmlkodlar'ına aittir.
  • 27-06-2009, 21:25:25
    #2
    Üyeliği durduruldu
    kodların yaptığı iş kısacası

    $file = "../js_slideshow/photos/01/" . $imagepath; //orjinal dosya

    orjinal dosyadan sadece küçük resim oluşturuyo asıl resme dokunmuyor *

    $modwidth = 150;

    orjinal resimi küçülterek kopyasını oluştuyor (büyükten küçüğe doğru yapıcaksın)

    $modwidth = 80;


    list($width, $height) = getimagesize($file) ;

    den sonra aynı işlemi tekrarlıycaksın ama 640*480 sabit w/h verirsen bozulur resim


    yani işlemler şöyle gidecek

    $modwidth = 640;
    .
    .
    .
    (c/p)
    yaptın
    imagejpeg($tn, $save, 100) ; thumb dizinine kayıt ediyor asıl dosyanın üzerine yazdır istediğin olur.

    $modwidth = 150;
    .
    .
    .

    kolay gelsin.
  • 27-06-2009, 22:20:13
    #3
    çok teşekkür ederim sonunda oldu.