Page 1 of 1

Problem With imagecreatefromjpeg

Posted: Fri Jul 23, 2010 1:22 pm
by 912bliss
Hi
The following code works on my computer but when i load it onto the server it works until it gets to imagecreatefromjpeg line then the program stops , the folders are all 0777
What i am trying to do is to scan through a folder and resize all images in that folder and move the resized images to a different folder

Any Idea what the problem could be

<?php

$dir = 'test';

$files2 = scandir($dir, 1);
$count=count($files2)-2;
for($i=0; $i<$count;$i++)
{

$uploadedfile ="test/".$files2[$i];

$resizedfile="pic/".$files2[$i];


list($width,$height)=getimagesize($uploadedfile);
$newwidth=330;
$newheight=($height/$width)*280;
if(($height/$width)<1.3){$newheight=($height/$width)*340;}
$tmp=imagecreatetruecolor($newwidth,$newheight);

$src =imagecreatefromjpeg($uploadedfile);


imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);



imagejpeg($tmp,$resizedfile,90);

}

?>

Re: Problem With imagecreatefromjpeg

Posted: Sat Jul 24, 2010 1:47 am
by Gargoyle
is the gd library available on the machine in question?

Re: Problem With imagecreatefromjpeg

Posted: Mon Jul 26, 2010 6:47 am
by 912bliss
I was getting the following error ,
Allowed memory size of 52428800 bytes exhausted (tried to allocate 12800 bytes) in createimage.php on line 48

i increase the memory limit from 24m to 50 m but still the same error , then increased it to 100m and it worked .

Why does imagecreatefromjpeg use that amount of memory just for an 240K image

Thanks for the help