Image Lib - Resize failure

#13
[eluser]gRoberts[/eluser]
Hey thanks for the reply.

I'm still using the CI code, but now I am using seperate code to calculate the size to resize to, and then passing these sizes directly rather then expect CI to handle it.

Code:
public function generate($source, $output, $width, $height) {

            $size = getimagesize($source);
            $original_width = $size[0];
            $original_height = $size[1];

            if($original_width > $original_height) {
                $new_width = $width;
                $new_height = $original_height*($width/$original_width);
            } else {
                $new_height = $width;
                $new_width = $original_width*($width/$original_height);
            }

            $config['image_library'] = 'GD2';
            //$config['library_path'] = '/usr/bin/X11';
            $config['source_image'] = $source;
            $config['maintain_ratio'] = TRUE;
            $config['create_thumb'] = false;
            $config['new_image'] = $output;
            $config['quality'] = 100;
            $config['width'] = $new_width;
            $config['height'] = $new_height;
            
            $this->base->image_lib->clear(); // added
            $this->base->image_lib->initialize($config);
            //echo $this->base->image_lib->width.'*'.$this->base->image_lib->height;
            if(!$this->base->image_lib->resize())
                die($this->base->image_lib->display_errors());
            return array(
                'width' => $new_width,
                'height' => $new_height
            );
        }


Messages In This Thread
Image Lib - Resize failure - by El Forum - 03-29-2008, 11:36 AM
Image Lib - Resize failure - by El Forum - 03-29-2008, 03:20 PM
Image Lib - Resize failure - by El Forum - 03-30-2008, 03:33 PM
Image Lib - Resize failure - by El Forum - 03-31-2008, 02:49 AM
Image Lib - Resize failure - by El Forum - 03-31-2008, 03:06 AM
Image Lib - Resize failure - by El Forum - 03-31-2008, 03:18 AM
Image Lib - Resize failure - by El Forum - 03-31-2008, 03:26 AM
Image Lib - Resize failure - by El Forum - 03-31-2008, 03:34 AM
Image Lib - Resize failure - by El Forum - 03-31-2008, 03:42 AM
Image Lib - Resize failure - by El Forum - 03-31-2008, 07:14 AM
Image Lib - Resize failure - by El Forum - 04-01-2008, 04:37 PM
Image Lib - Resize failure - by El Forum - 04-02-2008, 11:44 AM
Image Lib - Resize failure - by El Forum - 04-02-2008, 01:08 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.