I have this function here.....
function create_thumbnail($source,$destination, $thumb_width) {
$size = getimagesize($source);
$width = $size[0];
$height = $size[1];
$x = 0;
$y = 0;
if($width> $height) {
$x = ceil(($width - $height) / 2 );
$width = $height;
} elseif($height> $width) {
$y = ceil(($height - $width) / 2);
$height = $width;
}
$new_image = imagecreatetruecolor($thumb_width,$thumb_width)or die('Cannot Initialize new GD image stream');
$extension = get_image_extension($source);
if($extension=='jpg' || $extension=='jpeg')
$image = imagecreatefromjpeg($source);
if($extension=='gif')
$image = imagecreatefromgif($source);
if($extension=='png')
$image = imagecreatefrompng($source);
imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width,$thumb_width,$width,$height);
if($extension=='jpg' || $extension=='jpeg')
imagejpeg($new_image,$destination);
if($extension=='gif')
imagegif($new_image,$destination);
if($extension=='png')
imagepng($new_image,$destination);
}
And what this does it takes an image and resizes, but its not resizing the way I expected to, I was expecting it would take a wide image or a tall image or a normal size image and cut it off so it fits to that size, it does the resizing but it cuts off most of my images...I have been struggling with this for days and I cant seem to find a way to resize my images without cutting them off....I hope I can find some help and it would greatly appreciated...so, so tired....
For an example I have this image....
and when I ran that function for that image it returns this...
What I am expecting is that same image, just smaller.
I changed this part of my code...
imagecopyresampled($new_image,$image,0,0,0,0,$thumb_width,$thumb_width,$width,$height);
changed the $x
and $y
to '0' and '0' and this is what came up...
I close to what I am looking for but the full image is not there...it still gets cut off.