Welcome Guest, Not a member yet? Register   Sign In
Image manipulation woes, currently producing blank images
#1

[eluser]Robert May[/eluser]
I've been wailing my head against my upload/thumbnail generation script since yesterday. It's run at the end of a multiple file upload, so it runs a foreach loop for each item in the string passed by Ajax. I've finally got it to the point where it doesn't generate errors, but the thumbnail file being created is now just a 200x200 black square.

If anyone has any ideas I'd be most grateful!
The string arrives as file=blah.jpg&file=arr.jpg& etc. The array_pop removes the last item which only includes a &.
The paths are all correct and have been tested.
Here's the function:

Code:
function upload(){

            $newFileName = $this->input->post("newFileName");

            $fileArray     = explode('&', $newFileName);

            $badelete     = array_pop($fileArray);

            $result      = '';

            foreach($fileArray as $file){

                $aFile = explode('=', $file);

                $aFile = $aFile[1];

                

                $this->image_lib->clear();

                $sourceimage = $_SERVER['DOCUMENT_ROOT'].'/gallery/'.$aFile;



                $minusExtension = explode('.', $aFile, 2);

                $filename  = $minusExtension[0];

                $extension = $minusExtension[1];

                $thumbnail = $filename.'_thumb.'.$extension;

                $newimage = $_SERVER['DOCUMENT_ROOT'].'/gallery/'.$thumbnail;

                

                // Make squarethumb

                $config['image_library'] = 'GD2';

                $config['source_image'] = $sourceimage;

                $config['new_image']    = $newimage;

                $config['maintain_ratio'] = TRUE;

                $config['width'] = '200px';

                $config['height'] = '200px';

                $this->image_lib->initialize($config);

                if (!$this->image_lib->resize()){

                    echo "<br />Fullsize<br />";

                    echo $this->image_lib->display_errors();

                }

                else {

                    $this->image_lib->clear();

                    

                    if(!is_file($newimage)){

                        echo "Thumbnail file not found";

                    }

                    else {

                        $config2['image_library'] = 'GD2';

                        $config2['x_axis'] = 200;

                        $config2['y_axis'] = 200;

                        $config2['create_thumb'] = FALSE;

                        $config2['maintain_ratio'] = FALSE;

                        $config2['source_image'] = $newimage;

                        $this->image_lib->initialize($config2);

        

                        if (!$this->image_lib->crop()){

                            echo "<br />Thumbnail<br />";

                            echo $this->image_lib->display_errors();

                        }

                        $this->image_lib->clear();

                    }

                }

                $data = $this->gallery_model->add_image($aFile);
            }

    }
#2

[eluser]TheFuzzy0ne[/eluser]
Do you have access to ImageMagick? I'd be interested to see if you get the same results with that.
#3

[eluser]Robert May[/eluser]
I do have access to ImageMagick, but CI doesn't seem to like the path to it. The path is /usr/bin/convert. I've tried /usr/bin, /usr/bin/, /usr/bin/convert and /usr/bin/convert/. Any ideas?
#4

[eluser]TheFuzzy0ne[/eluser]
Please try /usr/bin/mogrify
#5

[eluser]Robert May[/eluser]
Nope, no luck. Still getting the 'Image processing failed. Please verify that your server supports the chosen protocol and that the path to your image library is correct.' error.
#6

[eluser]TheFuzzy0ne[/eluser]
OK, one last suggestion for now. Please change the path to "/usr/bin/" and the library name to "mogrify".
#7

[eluser]Robert May[/eluser]
Internal error from CI for that one, undefined method. Big Grin
It is rather odd that it doesn't like the normal path.
#8

[eluser]TheFuzzy0ne[/eluser]
I've been having a look at the image library. Looks like it wants the config array like this:

Code:
$config2['image_library'] = 'imagemagick';
$config2['library_path'] = '/usr/bin/mogrify';

I'm 99.999% sure this will work this time...
#9

[eluser]Robert May[/eluser]
Argh! Still no luck! I had a quick look in the library too, and it seems to append /convert to the library path if it's not there, so tried again but still no dice.
#10

[eluser]TheFuzzy0ne[/eluser]
Holy poop on a stick, this is becoming such a chore. I'm going to spend some time later tonight figuring out how to get ImageMagick working with Codeigniter. I can't see anything from with your code, but I don't use the image library often. Hopefully someone will pop on later on and point out something blatantly obvious, so we'll both be kicking ourselves.

Sorry I couldn't help more.




Theme © iAndrew 2016 - Forum software by © MyBB