PDA

View Full Version : Help with "memory exhausted" error.


smoked1
November 28th, 2005, 01:54 PM
Everything was fine til today. I tried doing a bulk upload and I keep getting this error:

"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 7020 bytes) in /usr/local/www/data-dist/photo_post/image-inc.php on line 84"

I have the memory limit set to 128M in php.ini so I don't understand why I am getting this error. I also ran "top" and everything looks good.

smoked1
November 28th, 2005, 02:56 PM
I just cleared out that category and uploaded the images again to uploads/99999 and I got this:

Processing JimDescalefish.jpg...
Processing JimDeweigh.jpg...
Processing kenthresh20002.jpg...
Processing Kurt.jpg...
Processing marktheshark.jpg...
Processing mikeTshark2.jpg...
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 28080 bytes) in /usr/local/www/data-dist/photo_post/image-inc.php on line 84

Chuck S
November 28th, 2005, 03:10 PM
If your using GD2 this can happen as GD is part of PHP and uses it's memory

If you have mogrify on the server try setting that path in config and selecting in global options imagemagick as your processor and try

My normal response with this error is to increase php memory as you have done and since yours is already at 128meg no use saying this.

smoked1
November 28th, 2005, 03:45 PM
The problem is that I have to use overlay watermarking so GD2 has to be used. I prefer to use ImageMagik but I can't because of the users requirements.

Chuck S
November 28th, 2005, 04:04 PM
well you should still be able to use overlay watermarking since gd is on the system

smoked1
November 28th, 2005, 04:39 PM
I think that worked but how do I get the overlay to show in the center of the image?

Chuck S
November 28th, 2005, 04:51 PM
In watermark.php file replace everything between these two bold lines



$imageInfo = getimagesize($srcfilename);
$width = $imageInfo[0];
$height = $imageInfo[1];

$logoinfo = getimagesize($watermark);
$logowidth = $logoinfo[0];
$logoheight = $logoinfo[1];

if( $Globals['gravity'] == "Center" ) {
$horizmargin = ( $width / 2 ) - ( $logowidth / 2 );
$vertmargin = ( $height / 2 ) - ( $logoheight / 2 );
}
elseif( $Globals['gravity'] == "NorthWest" ) {
// top left
$horizmargin = 0;
$vertmargin = 0;
}
elseif( $Globals['gravity'] == "NorthEast" ) {
// top right
$horizmargin = $width - $logowidth;
$vertmargin = 0;
}
elseif( $Globals['gravity'] == "SouthWest" ) {
// bottom left
$horizmargin = 0;
$vertmargin = $height - $logoheight;
}
elseif( $Globals['gravity'] == "North" ) {
// top middle
$horizmargin = ( ( $width - $logowidth ) / 2 );
$vertmargin = 0;
}
elseif( $Globals['gravity'] == "East" ) {
// middle right
$horizmargin = $width - $logowidth;
$vertmargin = ( $height / 2 ) - ( $logoheight / 2 );
}
elseif( $Globals['gravity'] == "South" ) {
// bottom middle
$horizmargin = ( ( $width - $logowidth ) / 2 );
$vertmargin = $height - $logoheight;
}
elseif( $Globals['gravity'] == "West" ) {
// middle left
$horizmargin = 0;
$vertmargin = ( $height / 2 ) - ( $logoheight / 2 );
}
else {
// bottom right
$horizmargin = $width - $logowidth;
$vertmargin = $height - $logoheight;
}

$photoImage = ImageCreateFromJPEG($srcfilename);
ImageAlphaBlending($photoImage, true);

smoked1
November 28th, 2005, 06:34 PM
That worked great. Thanks a bunch.:)