[eluser]megabyte[/eluser]
OK,
for those who are having this aame issue I found a solution. I didn't create it but I did find it for us all, lol.
If you are trying to resize images that are large, then you need to increase the memory usage like others have noted.
Well here's a function that calculates the amount of memory you need and increases it for you. Not sure if it works on all servers, but it did for me.
Code:
function setMemoryForImage( $filename ){
$imageInfo = getimagesize($filename);
$memoryLimitMB = 0;
$MB = 1048576; // number of bytes in 1M
$K64 = 65536; // number of bytes in 64K
$TWEAKFACTOR = 8; // Or whatever works for you
$memoryNeeded = round( ( $imageInfo[0] * $imageInfo[1]
* $imageInfo['bits']
* $imageInfo['channels'] / 8
+ $K64
) * $TWEAKFACTOR
);
//ini_get('memory_limit') only works if compiled with "--enable-memory-limit" also
//Default memory limit is 8MB so well stick with that.
//To find out what yours is, view your php.ini file.
$memoryLimit = 8 * $MB;
if (function_exists('memory_get_usage') &&
memory_get_usage() + $memoryNeeded > $memoryLimit)
{
$newLimit = $memoryLimitMB + ceil( ( memory_get_usage()
+ $memoryNeeded
- $memoryLimit
) / $MB
);
ini_set( 'memory_limit', $newLimit . 'M' );
return true;
}
else{
return false;
}
}
$filename being the full path to image