I am using codiginter 3X version. How to crop all image to 16:9 and how to calculate correct width and height ?
I tried, but some images are not cropping to correct ratio 16:9 .
Example :
list($width, $height) = getimagesize($source_path);
if($width > $height) {
$height_set = ($width/16)*9;
$config_image = array(
'source_image' => $source_path,
'new_image' => $target_path,
'maintain_ratio' => FALSE,
'width' => $width,
'height' => $height_set,
);
} else {
$height_set = ($width/16)*9;
$config_image = array(
'source_image' => $source_path,
'new_image' => $target_path,
'maintain_ratio' => FALSE,
'width' => $width,
'height' => $height_set,
);
}
$this->image_lib->clear();
$this->image_lib->initialize($config_image);
$this->image_lib->crop();