0

I have a function that pulls images from an external location and the arrive with the proportions of 952 x 390 but they are displayed on my site 960 by 380 is there anyway using PHP that I could change the ratio so they do not look so stretched?

Jess McKenzie
  • 8,345
  • 27
  • 100
  • 170
  • quick - you can just specify it in the image tag, img width=, height=, most browsers will display that way. – cartalot Dec 01 '12 at 00:49

1 Answers1

0

Use the codigniters Image Library and parse maintain_ratio as one of the attributes

 $this->load->library('image_lib');

 $params = array();
 $params['source_image'] = /path/to/image
 $params['new_image'] = /path/to/mynewimage
 $params['width'] = 960;
 $params['height'] = 380; //leave height or with only for aspect ratio to work
 $params['maintain_ratio'] = true;
 $this->image_lib->initialize($params);
 $this->image_lib->resize();
Elijan
  • 1,406
  • 1
  • 8
  • 11