$h) { $srcSize = $h; $srcY = 0; $srcX = ($w - $srcSize)/2; } elseif ($w < $h) { $srcSize = $w; $srcX = 0; $srcY = ($h - $srcSize)/2; } else { $srcSize = $w; $srcX = $srcY = 0; } $newImg = imagecreatetruecolor(THUMB_SIZE, THUMB_SIZE); imagecopyresampled($newImg, $img, 0, 0, $srcX, $srcY, THUMB_SIZE, THUMB_SIZE, $srcSize, $srcSize); if ($ext == ".jpg") imagejpeg($newImg, $newImgFile); else imagepng($newImg, $newImgFile); imagedestroy($img); imagedestroy($newImg); } return $newImgFile; } ?>