satal keto Posted November 19, 2007 Share Posted November 19, 2007 Hello I am trying to get some code which will resize images which are uploaded to my website using a form. The code I am using to resize the images atm is function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbHeight) { $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName"); $origWidth = imagesx($srcImg); $origHeight = imagesy($srcImg); $ratio = $origHeight / $thumbHeight; $thumbWidth = $origWidth / $ratio; $dst_img=ImageCreateTrueColor($thumbWidth,$thumbHeight); #imagecopyresampled($dst_img,$srcImg,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight); imagecopyresized($dst_img,$srcImg,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight); imagejpeg($dst_img,$thumbDirectory . "/" . $imageName); imagedestroy($dst_img); } The problem is when ever I try to run this code it is saying... Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 3264 bytes) in K:\WOS Stuff\www\sb\adminPhotos.php on line 5where line 5 is $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName"); I was wondering whether anyone had any idea's of some how that I would be able to resize the images without causing this error? Quote Link to comment https://forums.phpfreaks.com/topic/77952-resize-large-image/ Share on other sites More sharing options...
Wes1890 Posted November 19, 2007 Share Posted November 19, 2007 Change $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName"); to $srcImg = imagecreatefromjpeg("YOUR_PATH/".$imageName); But replace YOUR_PATH with your direct path. Because there could be an error with the $imagedirectory variable. Just a thought Quote Link to comment https://forums.phpfreaks.com/topic/77952-resize-large-image/#findComment-394582 Share on other sites More sharing options...
satal keto Posted November 19, 2007 Author Share Posted November 19, 2007 No unfortunately its not that I am using the wrong file, it gives the same result using both versions. Quote Link to comment https://forums.phpfreaks.com/topic/77952-resize-large-image/#findComment-394596 Share on other sites More sharing options...
Wes1890 Posted November 19, 2007 Share Posted November 19, 2007 Well it could also be that your script grabs just over the 8MB default memory limit of PHP. (although i think php5 has a default limit of 300mb). What version of php are you running? Run phpinfo() and check your version, also check your memory limit. You can edit memory_limit in your php.ini file to fix this, or you could edit your .htaccess file and add this line: php_value memory_limit 24M for a quick fix, if thats the problem Quote Link to comment https://forums.phpfreaks.com/topic/77952-resize-large-image/#findComment-394600 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.