Hi ich habe ein argen Problem mit NextGen Gallery nachdem ich die Bilder hochgeladen habe erscheint das:
Fatal error: Out of memory (allocated 112197632) (tried to allocate 20736 bytes) in /mnt/web1/40/39/5724139/htdocs/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php on line 179
ich glaube das hier die thumbnail Erzeugung scheitert..
hier der besagte ([...]/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php[...]) file:
(Zeile 179 ist mit einem /* ---->> 179 */ gekennzeichnet und rot markiert
PHP
<?php
/**
* gd.thumbnail.inc.php
*
* @author Ian Selby (ian@gen-x-design.com)
* @copyright Copyright 2006-2011
* @version 1.3.0 (based on 1.1.3)
* @modded by Alex Rabe
*
*/
[...]
//check to see if file exists
if(!file_exists($this->fileName)) {
$this->errmsg = 'File not found';
$this->error = true;
}
//check to see if file is readable
elseif(!is_readable($this->fileName)) {
$this->errmsg = 'File is not readable';
$this->error = true;
}
//if there are no errors, determine the file format
if($this->error == false) {
$data = @getimagesize($this->fileName);
if (isset($data) && is_array($data)) {
$extensions = array('1' => 'GIF', '2' => 'JPG', '3' => 'PNG');
$extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : '';
if($extension) {
$this->format = $extension;
} else {
$this->errmsg = 'Unknown file format';
$this->error = true;
}
} else {
$this->errmsg = 'File is not an image';
$this->error = true;
}
}
// increase memory-limit if possible, GD needs this for large images
// @ini_set('memory_limit', '128M');
if($this->error == false) {
// Check memory consumption if file exists
$this->checkMemoryForImage($this->fileName);
}
//initialize resources if no errors
if($this->error == false) {
switch($this->format) {
case 'GIF':
$this->oldImage = ImageCreateFromGif($this->fileName);
break;
case 'JPG':
[COLOR="Red"]/* --->>> 179 */ $this->oldImage = ImageCreateFromJpeg($this->fileName);[/COLOR]
break;
case 'PNG':
$this->oldImage = ImageCreateFromPng($this->fileName);
break;
}
if (!$this->oldImage) {
$this->errmsg = 'Create Image failed. Check memory limit';
$this->error = true;
} else {
$size = GetImageSize($this->fileName);
$this->currentDimensions = array('width'=>$size[0],'height'=>$size[1]);
$this->newImage = $this->oldImage;
}
}
if($this->error == true) {
if(!$no_ErrorImage)
$this->showErrorImage();
return;
}
}
/**
* Calculate the memory limit
*
*/
function checkMemoryForImage( $filename ){
if ( (function_exists('memory_get_usage')) && (ini_get('memory_limit')) ) {
$imageInfo = getimagesize($filename);
switch($this->format) {
case 'GIF':
// measured factor 1 is better
$CHANNEL = 1;
break;
case 'JPG':
$CHANNEL = $imageInfo['channels'];
break;
case 'PNG':
// didn't get the channel for png
$CHANNEL = 3;
break;
}
$MB = 1048576; // number of bytes in 1M
$K64 = 65536; // number of bytes in 64K
$TWEAKFACTOR = 1.68; // Or whatever works for you
$memoryNeeded = round( ( $imageInfo[0] * $imageInfo[1]
* $imageInfo['bits']
* $CHANNEL / 8
+ $K64
) * $TWEAKFACTOR
);
$memoryNeeded = memory_get_usage() + $memoryNeeded;
// get memory limit
$memory_limit = ini_get('memory_limit');
// PHP docs : Note that to have no memory limit, set this directive to -1.
if ($memory_limit == -1 ) return;
// Just check megabyte limits, not higher
if ( strtolower(substr($memory_limit, -1)) == 'm' ) {
if ($memory_limit != '') {
$memory_limit = substr($memory_limit, 0, -1) * 1024 * 1024;
}
if ($memoryNeeded > $memory_limit) {
$memoryNeeded = round ($memoryNeeded / 1024 / 1024, 2);
$this->errmsg = 'Exceed Memory limit. Require : '.$memoryNeeded. " MByte" ;
$this->error = true;
}
}
}
return;
}
/**
* Must be called to free up allocated memory after all manipulations are done
*
*/
function destruct() {
if(is_resource($this->newImage)) @ImageDestroy($this->newImage);
if(is_resource($this->oldImage)) @ImageDestroy($this->oldImage);
if(is_resource($this->workingImage)) @ImageDestroy($this->workingImage);
}
/**
* Returns the current width of the image
*
* @return int
*/
function getCurrentWidth() {
return $this->currentDimensions['width'];
}
/**
* Returns the current height of the image
*
* @return int
*/
function getCurrentHeight() {
return $this->currentDimensions['height'];
}
[...]
$this->ImageCopyResampled(
$this->workingImage,
$this->oldImage,
0,
0,
0,
0,
[...]
function createReflection($percent,$reflection,$white,$border = true,$borderColor = '#a4a4a4') {
$width = $this->currentDimensions['width'];
$height = $this->currentDimensions['height'];
$reflectionHeight = intval($height * ($reflection / 100));
$newHeight = $height + $reflectionHeight;
$reflectedPart = $height * ($percent / 100);
[...]
if($border == true) {
$rgb = $this->hex2rgb($borderColor,false);
$colorToPaint = imagecolorallocate($this->workingImage,$rgb[0],$rgb[1],$rgb[2]);
imageline($this->workingImage,0,0,$width,0,$colorToPaint); //top line
imageline($this->workingImage,0,$height,$width,$height,$colorToPaint); //bottom line
imageline($this->workingImage,0,0,0,$height,$colorToPaint); //left line
imageline($this->workingImage,$width-1,0,$width-1,$height,$colorToPaint); //right line
}
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $width;
$this->currentDimensions['height'] = $newHeight;
}
/**
* Flip an image.
*
* @param bool $horz flip the image in horizontal mode
* @param bool $vert flip the image in vertical mode
*/
function flipImage( $horz = false, $vert = false ) {
$sx = $vert ? ($this->currentDimensions['width'] - 1) : 0;
$sy = $horz ? ($this->currentDimensions['height'] - 1) : 0;
$sw = $vert ? -$this->currentDimensions['width'] : $this->currentDimensions['width'];
$sh = $horz ? -$this->currentDimensions['height'] : $this->currentDimensions['height'];
$this->workingImage = imagecreatetruecolor( $this->currentDimensions['width'], $this->currentDimensions['height'] );
[...]
// Check if this image is PNG or GIF, then set if Transparent
if( $this->format == 'GIF' || $this->format == 'PNG'){
imagealphablending($dst_image, false);
imagesavealpha($dst_image, true);
$transparent = imagecolorallocatealpha($dst_image, 255, 255, 255, 127);
imagefilledrectangle($dst_image, 0, 0, $dst_w, $dst_h, $transparent);
}
imagecopyresampled($dst_image , $src_image , $dst_x , $dst_y , $src_x , $src_y , $dst_w , $dst_h , $src_w , $src_h);
return true;
}
}
?>
Alles anzeigen
Hier ist nochmals der ganze code als .txt http://dl.dropbox.com/u/31533681/next-gen-tum-php.txt