Welcome Guest, Not a member yet? Register   Sign In
CI Image Manipulation
#2

[eluser]Référencement Google[/eluser]
I don't specially answer your question, I only put below a function I am using in one application that may help you. It resize an upload picture, then crop it in the middle height at specified dimensions:

Code:
function resize_crop($files, $path = 'public/gallery')
    {
        $errors = FALSE;

        foreach($files as $photo)
        {
            $config['image_library']  = 'GD2';
            $config['maintain_ratio'] = TRUE;
            $config['quality']        = 95;

            // Resize the image
            $config['width']        = 550;
            $config['height']       = 550;
            $config['source_image'] = realpath($path).'/'.$photo['file_name'];
            $this->initialize($config);

            if( ! $this->resize())
            {
                $errors = TRUE;
            }

            // Create the thumbnail
            $config['width']        = 260;
            $config['height']       = 100;
            $config['create_thumb'] = TRUE;
            $config['thumb_marker'] = 'th_';
            $config['master_dim']   = 'width';
            $this->initialize($config);

            if( ! $this->resize())
            {
                $errors = TRUE;
            }

            // Crop the thumbnail
            $config['source_image']   = realpath($path).'/th_'.$photo['file_name'];
            $config['create_thumb']   = FALSE;
            $config['maintain_ratio'] = FALSE;
            $config['quality']        = 85;
            $config['x_axis']         = 0;

            $imageSize = $this->get_image_properties($config['source_image'], TRUE);

            // Crop in the middle of height
            $config['y_axis'] = (($imageSize['height'] / 2) - ($config['height'] / 2));

            $this->initialize($config);

            if( ! $this->crop())
            {
                $errors = TRUE;
            }

            // Clear settings for next loop
            $this->clear();
            unset($config);
         }

         return ! $errors;
    }


Messages In This Thread
CI Image Manipulation - by El Forum - 03-11-2008, 12:37 PM
CI Image Manipulation - by El Forum - 03-11-2008, 12:54 PM
CI Image Manipulation - by El Forum - 03-11-2008, 01:15 PM
CI Image Manipulation - by El Forum - 03-11-2008, 01:51 PM
CI Image Manipulation - by El Forum - 03-11-2008, 01:59 PM
CI Image Manipulation - by El Forum - 03-11-2008, 02:11 PM
CI Image Manipulation - by El Forum - 03-11-2008, 02:54 PM
CI Image Manipulation - by El Forum - 03-11-2008, 02:58 PM
CI Image Manipulation - by El Forum - 03-11-2008, 03:47 PM
CI Image Manipulation - by El Forum - 03-11-2008, 06:32 PM
CI Image Manipulation - by El Forum - 03-12-2008, 09:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB