Welcome Guest, Not a member yet? Register   Sign In
Image resize problems
#1

[eluser]louis w[/eluser]
Having problems with the image lib and resizing images proportionally.

This is my config:
Code:
$config['image_library']     = 'gd2';
$config['source_image']     = $file_path;
$config['new_image']         = $resize_file_path;
$config['maintain_ratio']     = TRUE;
$config['master_dim']         = 'auto';
$config['width']         = $this->input->get('w');
//$config['height']         = $this->input->get('h');


When I do this and resize to 100 width, the width is 100, but the height is the original image size. I thought that maintain_ratio would scale the image proportionally?

I did see this post, but I did not have a image_thumb, so not appropriate.
http://ellislab.com/forums/viewthread/84992/

I almost want to do all the the new with/height logic myself, but feel it really should be built in.
#2

[eluser]steelaz[/eluser]
Try changing $config['master_dim'] from 'auto' to 'width';
#3

[eluser]louis w[/eluser]
Tried that, $config['master_dim'] = 'width'; gives the same result.
#4

[eluser]steelaz[/eluser]
Try setting height property to some small number, here is an example of what worked for me:

Code:
$config['image_library']  = 'gd2';
$config['source_image']   = $source_image;
$config['new_image']      = $new_image;
$config['maintain_ratio'] = TRUE;
$config['master_dim']     = 'width';
$config['width']          = $width;
$config['height']         = 100;
        
$this->image_lib->initialize($config);
#5

[eluser]louis w[/eluser]
Nice one steelaz, that worked.

Is that really how it is intended to work? Seems to me that if i wanted to fit an image proportionally into a certain width all i would need is the width and maintain_ratio.

I might have to extended the image lib to make it a little easier to scale images.




Theme © iAndrew 2016 - Forum software by © MyBB