Welcome Guest, Not a member yet? Register   Sign In
How do you scale/fit an image?
#1

CI3 Image Manipulation library can resize() or crop() image, but it would be great if it had a method to scale an image like scale()!

I need to scale an image, for example what ever the image size is i would like to resize it to 200x200.

To achieve that i have this code, but it still doesn't resize all the images in 200x200 size again i want to scale the image!
PHP Code:
$img_properties = [
            
'image_library'  => 'gd2',
            
'source_image'   => $image,
            
'create_thumb'   => false,
            
'maintain_ratio' => true,
            
'width'          => 200,
            
'height'         => 200,
            
'master_dim'     => 'auto'
        
];
        
$this->load->library('image_lib'$img_properties);
        
$this->image_lib->resize(); 

What would be the idea in this case?
Thanks and wish you a great day Smile
Reply
#2

create_thumb is probably what you want then
Reply
#3
Thumbs Up 

(06-22-2015, 03:00 PM)CroNiX Wrote: create_thumb is probably what you want then

Thanks, but enabling ''create_thumb'   => true'' didn't scale the image :/ it generates a 146x200 image., any other idea?

Attached Files Thumbnail(s)
   
Reply
#4

It seems it did scale it according to your settings? if you want it 200x200 then turn off maintain_ratio but it will then probably distort/stretch the image. If you want 200x200 with NO distortion than I don't think the image library can do that on its own. You'd need one step more and take the 146x200, create a new blank 200x200 image and center the 146x200 within that and save it.

Why does it have to be exactly 200x200? Can't you just create a 200x200px div and center the image in that? Basically same end result but don't need to process the image further.
Reply
Reply
Reply




Theme © iAndrew 2016 - Forum software by © MyBB