views:

27

answers:

1

I would expect that $config['maintain_ratio'] = TRUE; would cause the width to be calculated if I only specify a height. I guess I have to provide any large number for the height to make it work?

    $config['image_library']    = 'gd2';
    $config['source_image']     = $image_filepath;
    $config['new_image']        = $thumbnail_filepath;
    $config['maintain_ratio']   = TRUE;
    $config['height']           = $this->thumbnail_height;

    $this->image_lib->initialize($config);
+1  A: 

Correct, you MUST specify both height and width. Since the maintain_ratio option is enabled, the resize will be as close to the target size as possible while preserving the original aspect ratio.

However, if you want to make sure it's always a certain height, set the master_dim config option to 'height', then you can set width to anything and it will always make the resize image that height while maintaining aspect ratio with the width. Similar idea works to maintain width.

Mitchell McKenna