CodeIgniter Forums
Image resize, weird bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Image resize, weird bug? (/showthread.php?tid=7666)



Image resize, weird bug? - El Forum - 04-18-2008

[eluser]Chris Newton[/eluser]
So... why does this work:
Code:
function get_image($image_name,$time=NULL)
    {      
        $upload_info=$this->load->config('upload');
        $config['source_image']        =    $this->config->item('edit_path').$image_name;
        $config['quality']               =     100;
        list($config['width'],$config['height']) =    getimagesize($config['source_image']);  
        $config['width']-=1;
        $config['maintain_ratio']    =    FALSE;
        $config['dynamic_output']    =    TRUE;    
        $this->load->library('image_lib', $config);
        if ( ! $this->image_lib->resize())
        {
            echo $this->image_lib->display_errors();  
            var_dump($config);
        }
        else
        {
            echo $this->image_lib->resize();
        }
    }

when this doesn't:
Code:
function get_image($image_name,$time=NULL)
    {      
        $upload_info=$this->load->config('upload');
        $config['source_image']        =    $this->config->item('edit_path').$image_name;
        $config['quality']               =     100;
        list($config['width'],$config['height']) =    getimagesize($config['source_image']);  
        $config['maintain_ratio']    =    FALSE;
        $config['dynamic_output']    =    TRUE;    
        $this->load->library('image_lib', $config);
        if ( ! $this->image_lib->resize())
        {
            echo $this->image_lib->display_errors();  
            var_dump($config);
        }
        else
        {
            echo $this->image_lib->resize();
        }
    }

The only difference in #2 (where image resize is not working) is that I didn't subtract 1 from the image's width. I've tried round() and floor() just to be sure there's not some tiny fraction slipping in there somehow, I've tried adding / subtracting 0, adding 1 after I've subtracted it, and using settype(). The only thing that seems to make this dynamic_output instance of the resize is by making the width slightly different from the actual width.

Anyone have any idea why this is happening? I'm gonna go delve into the image_manipulation library to see if I can figure it out, but so far nothing's popping up.


Image resize, weird bug? - El Forum - 04-18-2008

[eluser]Lone[/eluser]
Are you sure that $config['width'] is set after the list command?


Image resize, weird bug? - El Forum - 04-18-2008

[eluser]Chris Newton[/eluser]
Regardless of where it's set, if width isn't shrunk by 1 it does not work.


Image resize, weird bug? - El Forum - 04-18-2008

[eluser]missionsix[/eluser]
why are you trying to resize an image to its current dimensions?

edit: you might want to use image_lib->display_errors(); to get the list of errors that are occuring


Image resize, weird bug? - El Forum - 04-20-2008

[eluser]Chris Newton[/eluser]
Resize is also used to copy. In this case I'm copying it to dynamic output on screen as part of a larger operation.

display_errors didn't give me much clue at the time. I'll turn them back on and copy out the response when I get a few.