Arkadaşlar bir ara bir upload fonksiyonu bulmuştum.Onun resizesini kullanıyorum fakat onunki boyutu değiştirir değiştirmez resmi bi garip gösteriyor.Kalitesi acaip bozuluyor.

$simg = imagecreatefromjpeg($dosyacik);   // Make A New Temporary Image To Create The Thumbanil From 
      $currwidth = imagesx($simg);   // Current Image Width 
      $currheight = imagesy($simg);   // Current Image Height 
	  
if($currwidth > $twidth2){ // Eğer Resim Fazla Büyükse

      if ($currheight > $currwidth) {   // If Height Is Greater Than Width 
         $zoom = $twidth2 / $currheight;   // Length Ratio For Width 
         $newheight = $theight2;   // Height Is Equal To Max Height 
         $newwidth = $currwidth * $zoom;   // Creates The New Width 
}// Yükseklik Genişlikten Büyükse
else{    // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) 
        $zoom = $twidth2 / $currwidth;   // Length Ratio For Height 
        $newwidth = $twidth2;   // Width Is Equal To Max Width 
        $newheight = $currheight * $zoom;   // Creates The New Height 
} // Yükseklik Genişlikten Büyük Değilse

      $dimg = imagecreate($newwidth, $newheight);   // Make New Image For Thumbnail 
      imagetruecolortopalette($simg, false, 256);   // Create New Color Pallete 
      $palsize = ImageColorsTotal($simg); 
	  
for ($i = 0; $i < $palsize; $i++) {   // Counting Colors In The Image 
       $colors = ImageColorsForIndex($simg, $i);   // Number Of Colors Used 
       ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); 
} // For
      imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);
fonksiyonun içindeki resize bölümü neyin neye yaradığını biliyorum fakat kalitenin neden bozulduğunu bilmiyorum yardımcı olursanız sevinirim