Autor Zpráva
jrw
Profil
Na zmenšení uploadovaných fotek jsem použil tento script. Pokud nahraju menší fotku (třeba 300 kB) tak to funguje pokud je fotka větší (třeba 1MB) už to nefunguje. Nevíte někdo čím by to mohlo být? Na počítači mi to funguje bez omezení. Jinak hodnoty na serveru na hostingu jsou:

upload_max_filesize = 2M
post_max_size = 8M
memory_limit = 8M
max_input_time = 60

/** Převzorkování obrázku GIF, PNG nebo JPG
* @param string $file_in název zmenšovaného souboru
* @param string $file_out název výsledného souboru
* @param int $width šířka výsledného obrázku
* @param int $height výška výsledného obrázku
* @return bool true, false v případě chyby
* @copyright Jakub Vrána, http://php.vrana.cz
*/

function image_resize($file_in, $file_out, $width, $height)
{
$imagesize = getimagesize($file_in);
if ((!$width && !$height) || !$imagesize[0] || !$imagesize[1]) {
return false;
}
if ($imagesize[0] == $width && $imagesize[1] == $height) {
return copy($file_in, $file_out);
}
switch ($imagesize[2]) {
case 1: $img = imagecreatefromgif($file_in); break;
case 2: $img = imagecreatefromjpeg($file_in); break;
case 3: $img = imagecreatefrompng($file_in); break;
default: return false;
}
if (!$img) {
return false;
}
$img2 = imagecreatetruecolor($width, $height);
imagecopyresampled($img2, $img, 0, 0, 0, 0, $width, $height, $imagesize[0], $imagesize[1]);
if ($imagesize[2] == 2) {
return imagejpeg($img2, $file_out);
} elseif ($imagesize[2] == 1 && function_exists("imagegif")) {
imagetruecolortopalette($img2, false, 256);
return imagegif($img2, $file_out);
} else {
return imagepng($img2, $file_out);
}
}
Toto téma je uzamčeno. Odpověď nelze zaslat.

0