Welcome Guest, Not a member yet? Register   Sign In
Problem with image manipulation (resizing)
#1

[eluser]tommizzle[/eluser]
Hi all,

I'm currently having a problem with resizing an image using CI's image manipulation class. Here is my controller:

Code:
<?php

class Photo extends Controller {
    
    function _remap($username)
    {    
        
        $data = array();
        
        $this->load->helper('file');
        $this->load->library('image_lib');
        
        $data['userid'] = $this->Autoload_model->get_userid_from_username($username);
        $data['upload_success'] = false;
        $data['is_my_profile'] = false;
        
        if($this->input->post('upload_image')):
            
            $upload_image['file_name'] = $data['userid'];
            $upload_image['upload_path'] = './images/profile/';
            $upload_image['allowed_types'] = 'gif|jpg|png';
            $upload_image['max_width']  = '1024';
            $upload_image['max_height']  = '768';
            $upload_image['overwrite']  = TRUE;
            
            $this->load->library('upload', $upload_image);
        
            if ( ! $this->upload->do_upload()):
                $data['error'] = array('error' => $this->upload->display_errors());
            else:
                $data['upload_success'] = true;
            endif;
            
            $config['image_library'] = 'gd2';
            $config['source_image'] = './images/profile/' . $data['userid'] . '.jpg';
            $config['new_image'] = './images/profile/new_image.jpg';
            $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            $config['width'] = 50;
            $config['height'] = 50;
            
            $this->load->library('image_lib', $config);
            
            if ( ! $this->image_lib->resize()):
                echo $this->image_lib->display_errors();
            else:
                echo 'Resize Success';
            endif;
            
        endif;
    
        
        
        if($this->input->post('delete_image')):
            unlink('./images/profile/' . $data['userid'] . '.jpg');
        endif;
        
        
        $data['has_photo'] = read_file('./images/profile/' . $data['userid'] . '.jpg');
        
        if($this->authlib->getUserName() == $username) $data['is_my_profile'] = true;
            
        $this->load->view('photo',$data);
    }

}
    
?>

and my view:
Code:
<?php
if(isset($error)) echo $error;

if($has_photo != false):
        echo '<img src="/images/profile/' . $userid . '.jpg" alt="My Profile Image" />';
else:
        echo '<img src="/images/profile/placeholder.png" alt="My Profile Image" />';
endif;

if($is_my_profile === true):
?&gt;
    &lt;form action="" method="post" enctype="multipart/form-data"&gt;
        &lt;input type="file" name="userfile" size="20" /&gt;
        &lt;input type="submit" name="upload_image" value="upload" /&gt;
        &lt;?php
        if($has_photo != false):
        ?&gt;
            &lt;input type="submit" name="delete_image" value="delete" /&gt;
        &lt;?php
        endif;
        ?&gt;
        
        
    &lt;/form&gt;
&lt;?php
endif;

if($upload_success === true) echo 'Success!';
?&gt;

The image is uploading, and then I'm even getting 'Resize Success', but it's not resizing or creating a new thumb in my chosen dir. I tried the normal 'GD' library too, and that didn't work either.

Has anybody got any ideas what's going wrong here? Any help would be appreciated Smile

Thanks guys!

Tom


Messages In This Thread
Problem with image manipulation (resizing) - by El Forum - 11-16-2009, 03:15 AM
Problem with image manipulation (resizing) - by El Forum - 11-16-2009, 04:01 AM
Problem with image manipulation (resizing) - by El Forum - 11-16-2009, 04:08 AM
Problem with image manipulation (resizing) - by El Forum - 11-16-2009, 04:33 AM
Problem with image manipulation (resizing) - by El Forum - 11-16-2009, 04:41 AM
Problem with image manipulation (resizing) - by El Forum - 11-24-2009, 10:40 AM
Problem with image manipulation (resizing) - by El Forum - 02-17-2010, 04:21 AM
Problem with image manipulation (resizing) - by El Forum - 02-17-2010, 04:29 AM
Problem with image manipulation (resizing) - by El Forum - 02-17-2010, 04:32 AM
Problem with image manipulation (resizing) - by El Forum - 02-17-2010, 04:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB