CodeIgniter Forums
GD / Image_lib issues - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: GD / Image_lib issues (/thread-2731.html)



GD / Image_lib issues - El Forum - 08-21-2007

[eluser]stevefink[/eluser]
Does anyone happen to see what I'm doing wrong here? I'm trying to create thumbnails of images uploaded to my server using the Image_lib library with the following code:

Code:
function upload()
    {
        if($_FILES) {
            set_time_limit(30);

            $uploadDir = "uploads";

            $filename = ereg_replace("[^A-Za-z0-9.]", "",       $_FILES['Filedata']['name']);
            $uploadFile = $uploadDir . "/" . $filename;
            move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile);
            chmod($uploadFile, 0777);
            
            // let's create a thumbnail while we're here.
            $config['image_library'] = 'GD';
            $config['source_image'] = "$uploadFile";
            $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            $config['width'] = 75;
            $config['height'] = 50;

            $this->load->library('image_lib', $config);
            $this->image_lib->resize();
            
            //$this->autodb->insert_photo($uploadFile);
            echo("This is complete!");
        }
        else
        {
            //$this->load->view('console/photos_view');
            die("Please contact the system administrator.");
        }
    }

The images get properly moved over to their respective directory. GD is also built into my PHP binary as verified via phpinfo(). No thumbnails are unfortunately being created though.

Can anyone suggest a way I can troubleshoot this as I'm not seeing any explicit errors that might imply something I'm doing incorrectly.

- sf


GD / Image_lib issues - El Forum - 08-21-2007

[eluser]stevefink[/eluser]
I added some debugging and found this in my logs:

DEBUG - 2007-08-21 20:16:21 --> Language file loaded: language/english/imglib_lang.php
ERROR - 2007-08-21 20:16:21 --> You must specify a source image in your preferences.
DEBUG - 2007-08-21 20:16:21 --> Image Lib Class Initialized

My source image is set though as you can see in my code above: $config['source_image'] = "$uploadFile";

Weird.


GD / Image_lib issues - El Forum - 08-21-2007

[eluser]stevefink[/eluser]
Actually, sorry. I keep posting to myself. I think the source image wasn't being seen because I loaded the library 'automatically' through autoload.php, at which point $config isn't passed to it.

I removed it from there and loaded it directly from the controller's method.

After the following I receive an error in my PHP logs:

DEBUG - 2007-08-21 20:19:49 --> $uploadFile: uploads/IMG0595.JPG
DEBUG - 2007-08-21 20:19:49 --> Image Lib Class Initialized

[21-Aug-2007 20:19:49] PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 9088 bytes) in /Applications/MAMP/htdocs/f1auto_ci/system/libraries/Image_lib.php on line 1140


GD / Image_lib issues - El Forum - 08-21-2007

[eluser]stevefink[/eluser]
Upped my memory_limit in php.ini, all is well now, phew!


GD / Image_lib issues - El Forum - 08-22-2007

[eluser]Crimp[/eluser]
Thanks for keeping us updated. ;-)


GD / Image_lib issues - El Forum - 08-22-2007

[eluser]Derek Allard[/eluser]
Yeek, that's a pretty low memory size. Was that a mamp default, or did you change it for something else?


GD / Image_lib issues - El Forum - 08-22-2007

[eluser]Crimp[/eluser]
MAMP comes with 8 out of the box. It always reminds you of that fact when it comes to uploading a file after a MAMP update. ;-)

Does any host actually default to a setting this low? I have yet to see it.


GD / Image_lib issues - El Forum - 08-22-2007

[eluser]stevefink[/eluser]
No idea Crimp. I host all of my own applications on my own 1U PE1850 box. :-) Any colo that does shared hosting on an 8M memory limit won't be keeping clients for too long ..


GD / Image_lib issues - El Forum - 08-22-2007

[eluser]Derek Allard[/eluser]
I've rarely seen 8M. I've seen 8M (usually 16M) when doing some EE debugging for various people, but the "norm" seems to be 32M or more. At EngineHosting we give 64M on the base-line plans.