I am trying to create simple thumbnail generation. I based it on another question here on Stack Overflow, but simplified the code for my needs. It's supposed to take an image and shrink it based only on height.
function create_thumbnail($original_pic, $intended_heigth){
$info = getimagesize($original_pic);
$actual_width = $info[0];
$actual_height = $info[1];
if($info['mime'] == 'image\jpeg'){
$src = imagecreatefromjpeg($original_pic);
}else{
return false;
}
$ratio = $intended_heigth / $actual_height;
$newheight = $intended_heigth;
$newwidth = $actual_width * $ratio;
$writex = 0;
$writey = 0;
$thumbnail = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($thumbnail, $src, $writex, $writey, 0, 0, $newwidth, $newheight, $actual_width, $actual_height);
return imagejpeg($thumbnail);
}
And then I am trying to echo id like this
<?php $original_pic = "images/info/7/01.jpg"; ?>
<img src="<?php create_thumbnail($original_pic, 90); ?>">
And this does nothing. But in the original code, there was the $writex defined this way $writex = round(($mintednded_width - $newwidth) / 2); But I don't really understand what is this even for. Any ideas?