CodeIgniter Forums
The first resizing does not consider the maintain ratio - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: The first resizing does not consider the maintain ratio (/showthread.php?tid=33296)



The first resizing does not consider the maintain ratio - El Forum - 08-21-2010

[eluser]Unknown[/eluser]
Hi!

First, I apologize for the my bad english knowledge.
My problem is that one of the first image after the resizing does not consider the maintain ratio:

http://www.imageserve.info/img_store/2010/08/21/3/33e164c8cf9dc0a3407568f68c8fda92.jpg

The second scaling problem is, they are working properly.

Code:
$this->load->library('image_lib');
        
        
        $config_small = array(
            'image_library'    => 'GD2',
            'source_image'    => 'media/covers/'.$this->Common->create_dirname($this->db->insert_id()).'/'.$this->db->insert_id().'.jpg',
            'thumb_marker'    => '-small',
            'create_thumb'    => TRUE,
            'maintain_ratio'=> TRUE,
            'width'            => 50,
            //'height'        => 300,
        );
        
        
        $this->image_lib->initialize($config_small);
        $this->image_lib->resize();
        
        
        
        $config_middle = array(
            'image_library'    => 'GD2',
            'source_image'    => 'media/covers/'.$this->Common->create_dirname($this->db->insert_id()).'/'.$this->db->insert_id().'.jpg',
            'thumb_marker'    => '-middle',
            'create_thumb'    => TRUE,            
            'maintain_ratio'=> TRUE,
            'width'            => 100,
            //'height'        => 400,
        );
        
        
        $this->image_lib->initialize($config_middle);
        $this->image_lib->resize();
        
        
        $config_large = array(
            'image_library'    => 'GD2',
            'source_image'    => 'media/covers/'.$this->Common->create_dirname($this->db->insert_id()).'/'.$this->db->insert_id().'.jpg',
            'thumb_marker'    => '-large',
            'create_thumb'    => TRUE,
            'maintain_ratio'=> TRUE,
            'width'            => 200,
            //'height'        => 120,
        );
        
        
        $this->image_lib->initialize($config_large);
        $this->image_lib->resize();

Anyone has any idea what could it be?
Thank you in advance for your help.


The first resizing does not consider the maintain ratio - El Forum - 08-21-2010

[eluser]gvillavizar[/eluser]
I solved this same problem just yesterday, the problem is you MUST specify a height in order to maintain the ratio.