php - My codeigniter image manipulation library isn't working the way i want it to work -
i have image. want size 500x250. want maintain image ratio. plan re-size , crop. code resizing image given below.
$config['image_library'] = 'gd2'; $config['source_image'] = './pictures/'.$pic_name; $config['maintain_ratio'] = true; $config['width'] = 500; $this->load->library('image_lib', $config); $this->image_lib->resize();
after resizing it, size of image 500x768. trying crop it. code cropping given below.
$config['image_library'] = 'gd2'; $config['source_image'] = './pictures/'.$pic_name; $config['x_axis'] = '0'; $config['y_axis'] = '0'; $config['height'] = 250; $config['width'] = 500; $this->image_lib->initialize($config); $this->image_lib->crop();
now size of image becoming 163x250. can't figure out wrong code. appreciated. in advance.
i not sure image_lib
think not accounting aspect ratio becoming lesser required sizes when getting resized.
suppose there image say: 1000 x 300
when resize becomes 500 x 150 (because maintaining aspect ratio)
when crop 500 x 250, going end either different size, or skewed images.
what need is, dynamically decide side (height or width) has lesser value , resize side maintaining aspect ratio , crop it. way, image have enough content cropped @ mentioned sizes.
Comments
Post a Comment