I'm using a script i found to generate thumbnails, but i'm getting an error in the first in lines 3 and 4. I'm guessing one of the functions is deprecated (it's a year old), but i really have no idea. GD support is enabled. I'm reading linked questions and realizing there is something i'm not getting about isset, but i'm not sure how to write this for both 'image' and 'width', it also seems like it is set in the next few lines. All help appreciated.
Notice: Undefined index: image in C:\xampp\htdocs\thumbnail\thumbnail.php on line 3
Notice: Undefined index: width in C:\xampp\htdocs\thumbnail\thumbnail.php on line 4
<?php
$imageSrc = (string)$_GET['image'];
$width = $_GET['width'];
if (is_numeric($width) && isset($imageSrc)){
header('Content-type: image/jpeg');
makeThumb($imageSrc, $width);
}
function makeThumb($src,$newWidth) {
// read the source image given
$srcImage = imagecreatefromjpeg($src);
$width = imagesx($srcImage);
$height = imagesy($srcImage);
// find the height of the thumb based on the width given
$newHeight = floor($height*($newWidth/$width));
// create a new blank image
$newImage = imagecreatetruecolor($newWidth,$newHeight);
// copy source image to a new size
imagecopyresized($newImage,$srcImage,0,0,0,0,$newWidth,$newHeight,$width,$height);
// create the thumbnail
imagejpeg($newImage);
}
?>
I realize generating scripts on the fly for every page load is not efficient, but i'm just trying to get something working.
I made the the third change suggested by Lawrence and i'm still getting an error:
Notice: Undefined variable: width in C:\xampp\htdocs\thumbnail\thumbnail.php on line 13