Welcome Guest, Not a member yet? Register   Sign In
The problem with image_lib
#8

[eluser]dmorin[/eluser]
try

Code:
<?php
class resizemodel extends Model {
    
    public function __construct() {
        parent::Model();
    }
    
    public function createAvatar ($fileName) {
        $this->load->library('image_lib');

        $big_img = '/dev.icq-mobi.ru/www/upload/big.jpg';
        $small_img = '/dev.icq-mobi.ru/www/upload/small.jpg';
        list($width, $height, $type, $attr) = getimagesize($fileName);
            
        if ($width > 640 OR $height > 480)
        {
            $config['image_library'] = 'gd2';
            $config['source_image'] = $fileName;
            $config['maintain_ratio'] = TRUE;
            $config['new_image'] = $big_img;
            $config['width'] = 640;
            $config['height'] = 480;
            $this->image_lib->initialize($config);
            $this->image_lib->resize();
            $this->image_lib->clear();
        }
        else
        {
            copy($fileName, $big_img);
        }
        
        if ($width > 120 OR $height > 80)
        {
            $config['image_library'] = 'gd2';
            $config['source_image'] = $fileName;
            $config['maintain_ratio'] = TRUE;
            $config['new_image'] = $small_img;
            $config['width'] = 120;
            $config['height'] = 80;
            $this->image_lib->initialize($config);
            $this->image_lib->resize();
        }
        else
        {
            copy($fileName, $small_img);
        }
    }
}
?>

Edit: Moved the load image library out of the first if statement...oops. Also, I haven't actually tested this...there may be other errors. This is just a guide.


Messages In This Thread
The problem with image_lib - by El Forum - 01-06-2009, 01:33 PM
The problem with image_lib - by El Forum - 01-06-2009, 07:25 PM
The problem with image_lib - by El Forum - 01-07-2009, 03:34 AM
The problem with image_lib - by El Forum - 01-07-2009, 08:13 AM
The problem with image_lib - by El Forum - 01-07-2009, 11:37 AM
The problem with image_lib - by El Forum - 01-07-2009, 12:05 PM
The problem with image_lib - by El Forum - 01-07-2009, 12:06 PM
The problem with image_lib - by El Forum - 01-07-2009, 12:17 PM
The problem with image_lib - by El Forum - 01-07-2009, 01:31 PM
The problem with image_lib - by El Forum - 01-24-2009, 03:40 PM
The problem with image_lib - by El Forum - 01-24-2009, 04:43 PM
The problem with image_lib - by El Forum - 01-24-2009, 06:07 PM
The problem with image_lib - by El Forum - 08-04-2009, 10:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB