Jump to content
php.lv forumi

Recommended Posts

Problēma ielādējot palielu bildi, lai to samazinātu thumbnailā

Fatal error: Allowed memory size of 13631488 bytes exhausted (tried to allocate 29996 bytes) in neteikšu

 

PHP konfigurācijā ir

memory_limit = 128M

NETICU ka ar 128mb nepietiek lai samazinātu 700x1000px bildīti......

 

P.S uzliekot ar iniset fiju 12mb uzreiz tie 29996 baiti pamazinaajaas uz ~7000 bet iniset neļāva pielikt vairāk par 12mb :(

 

kur varētu būt nolāpītā problēma?

Link to post
Share on other sites

uz php_ini() parāda ka memory limits ir uzlikts tik cik ar ini_set noraadu kautvai 128MB vai 256 utt.. bet tur blakus ir master_value un tas staav 12mb, kā lai izmaina master value? mož tas kko šakarē?

 

  function foto_mazizmers($filetype, $origfile, $thumbfile, $new_w, $new_h) {

global $settings;

if ($filetype == "image/gif" || $filetype == "image/x-gif") { $origimage = imagecreatefromgif($origfile); }
elseif ($filetype == "image/jpeg" || $filetype == "image/pjpeg") { $origimage = imagecreatefromjpeg($origfile); }
elseif ($filetype == "image/png" || $filetype == "image/x-png") { $origimage = imagecreatefrompng($origfile); }

$old_x = imagesx($origimage);
$old_y = imagesy($origimage);

if ($old_x > $new_w || $old_y > $new_h) {
	if ($old_x < $old_y) {
		$thumb_w = round(($old_x * $new_h) / $old_y);
		$thumb_h = $new_h;
	} elseif ($old_x > $old_y) {
		$thumb_w = $new_w;
		$thumb_h = round(($old_y * $new_w) / $old_x);
	} else {
		$thumb_w = $new_w;
		$thumb_h = $new_h;
	}
} else {
	$thumb_w = $old_x;
	$thumb_h = $old_y;
}

if ($settings['thumb_compression'] == "gd1") {
	$thumbimage = imagecreate($thumb_w,$thumb_h);
	$result = imagecopyresized($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
} else {
	$thumbimage = imagecreatetruecolor($thumb_w,$thumb_h);
	$result = imagecopyresampled($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
}

touch($thumbfile);

if ($filetype == "image/gif" || $filetype == "image/x-gif") { imagegif($thumbimage, $thumbfile); }
elseif ($filetype == "image/jpeg" || $filetype == "image/pjpeg") { imagejpeg($thumbimage, $thumbfile); }
elseif ($filetype == "image/png" || $filetype == "image/x-png") { imagepng($thumbimage, $thumbfile); }
}

 

RINDIŅA:

	elseif ($filetype == "image/jpeg" || $filetype == "image/pjpeg") { $origimage = imagecreatefromjpeg($origfile); }[code]

funkcija laba, lietoju jau sen, uzliekot uz cita servera uzreiz kakas spļauj ārā ar saviem memory_****

Link to post
Share on other sites

mhhhh hmmm.. fails itkā korekts, testēju ar windows sample pictures (ar taam ainavaam) padodot failu ar otru fju ko atradu, tur viss normāli :)

Link to post
Share on other sites
  • 2 weeks later...
×
×
  • Create New...