Welcome Guest, Not a member yet? Register   Sign In
GD / Image_lib issues

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:

function upload()
        if($_FILES) {

            $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);
            echo("This is complete!");
            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

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";


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

Upped my memory_limit in php.ini, all is well now, phew!

Thanks for keeping us updated. ;-)

[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?

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.

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 ..

[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.

Theme © iAndrew 2016 - Forum software by © MyBB