Welcome Guest, Not a member yet? Register   Sign In
Image manipulation

(This post was last modified: 07-29-2017, 11:41 PM by theedo.)

Hi people! How's going?

Today I'm here to ask you something about the image manipulation. I studied it a lot, but I need help with something.
I'm making a "Change profile picture" like facebook/instagram/twitter/......and more. 

I want the image that user upload becomes smaller, not in size(width and height I mean) but in dimension. Instead: I've an image of 4mb -> it must be smaller than 4mb when the user upload on my website.

And do you have some suggestion about display the image in profile user? Instead the image has 800 as width 400 as height and my profile-box is 215w x 215h, how can I crop the image without lose anything?

I post here my actual upload function, maybe you can help me! Thank you

PHP Code:
public function changeProfilePicture(){
       $config['upload_path'         './uploads/images/profile/pictures/';
       $config['allowed_types'       'gif|jpg|png';
       $config['encrypt_name'        TRUE;


       if (!$this->upload->do_upload('photo_input'))
               $error = array('error' => $this->upload->display_errors());
               echo json_encode($error);
               $a = array(
                   'user_id' => $this->session->userdata('uid'),
                   'image' => $info['file_name']
= array(
                   'success' => TRUE
= array(
                   'fail' => TRUE
//$data = array('upload_data' => $this->upload->data());
                   $config['image_library'] = 'gd2';
                   $config['source_image'] = $info['full_path'];
                   $config['create_thumb'] = FALSE;
                   $config['maintain_ratio'] = TRUE;
                   $config['height']    = "215";
                   $config['width'] = "215";
                   $config['new_image'] = "./uploads/images/profile/pictures/"//you should have write permission here..
                   echo json_encode($d);
               } else {

(Yes, actually I resize the image to 215h 215w, but I don't want do this because if the user click on the image, obviously, he'll see that 215x215 and not with the real dimensions)

Messages In This Thread
Image manipulation - by theedo - 07-29-2017, 11:39 PM
RE: Image manipulation - by InsiteFX - 07-30-2017, 04:33 AM
RE: Image manipulation - by theedo - 07-30-2017, 12:20 PM
RE: Image manipulation - by jarmen_kell - 07-30-2017, 05:01 PM
RE: Image manipulation - by Diederik - 07-30-2017, 02:08 PM
RE: Image manipulation - by InsiteFX - 07-30-2017, 05:22 PM
RE: Image manipulation - by Martin7483 - 07-31-2017, 12:43 AM

Theme © iAndrew 2016 - Forum software by © MyBB