Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Resize large image

    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
    PHP Code:
    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 5
    where 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?

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    159
    Thanks
    2
    Thanked 15 Times in 15 Posts
    You need to change the value for: memory_limit

    This can be found in your php.ini configuration file on the server. (Default: 32M)




    ~Jordan
    Remember The Thank You Button Is Your Friend =]

    [ PHP / Javascript / VisualBasic / HTML / DHTML / CSS / .NET / MySQL ]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •