Code: Select all
function resize_image($max_width,$max_height){
$width = $this->getWidth($this->image_location);
$height = $this->getHeight($this->image_location);
$new_width = "";
$new_height = "";
$with_scale = $width/$max_width;
$height_scale = $height/$max_height;
if($with_scale > $height_scale){
$new_width = $max_width;
$new_height = ($max_width/$width) * $height;
}else{
$new_height = $max_height;
$new_width = ($max_height/$height) * $width;
}
$newImage = imagecreatetruecolor($new_width,$new_height);
$source = imagecreatefromjpeg($this->image_location);
imagecopyresampled($newImage,$source,0,0,0,0,$new_width,$new_height,$width,$height);
imagejpeg($newImage,$this->new_location,85);
chmod($this->new_location, 0777);
return $this->new_location;
}
I want to put this picture with 200x100 over a white square 200x200 vertical align.
How can I change this code for this ?
Thanks