Welcome Guest, Not a member yet? Register   Sign In
Upload, Crop, Resize, and Thumb
#1

[eluser]merrick.christensen[/eluser]
Ok. I'm not sure what the heck is going on here. I am getting very frustrated and would appreciate any help hat could be offered.

The user is uploading an image. It sends them to a crop utility, they crop and it resizes, then it would create a thumb from the crop. My issue is that it is applying the thumb resize to the crop rather then creating a new one. Even thought the property is set, in fact if I access the process_thumb function directly it will create a thumb, but not with PHP. Any help would be so appreciated.

Code:
<?php

function process_image($image_url)
    {
        $config['image_library'] = 'gd2';
        $config['source_image'] = './uploads/' . $image_url;
        $config['maintain_ratio'] = FALSE;
        $config['width'] = $this->input->post('w');
        $config['height'] = $this->input->post('h');
        $config['x_axis'] = $this->input->post('x');
        $config['y_axis'] = $this->input->post('y');
        
        $this->image_lib->initialize($config);
        
        if ( ! $this->image_lib->crop())
        {
            echo $this->image_lib->display_errors();
        }
        else {
        if (! $this->process_resize($image_url)){
                echo "Failed Resize";
            } else{
                if(! $this->process_thumb($image_url)){
                    echo "Failed Thumb";
                } else{
                    echo "success";
                }
            }
        }
    }
    
    function process_resize($image_url)
    {    
        $this->image_lib->clear();
        $config['image_library'] = 'gd2';
        $config['source_image'] = './uploads/' . $image_url;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 162;
        $config['height'] = 246;

        $this->image_lib->initialize($config);
        
        if ( ! $this->image_lib->resize()){
            return false;
        } else{
            return true;        
        }
    }
    
    function process_thumb($image_url)
    {
        $this->image_lib->clear();
        $config['image_library'] = 'gd2';
        $config['source_image'] = './uploads/' . $image_url;
        $config['maintain_ratio'] = TRUE;
        $config['create_thumb'] = TRUE;
        $config['width'] = 32;
        $config['height'] = 32;
        
        $this->image_lib->initialize($config);
        
        //I resize and all that goodness
        if(! $this->image_lib->resize()){
            //echo $this->image_lib->display_errors();
            return false;
        } else{
            //echo "Nice";
            return true;
        }    
    }


Messages In This Thread
Upload, Crop, Resize, and Thumb - by El Forum - 12-11-2009, 04:46 PM
Upload, Crop, Resize, and Thumb - by El Forum - 12-11-2009, 06:26 PM
Upload, Crop, Resize, and Thumb - by El Forum - 12-12-2009, 06:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB