stublackett Posted January 26, 2011 Share Posted January 26, 2011 Hi Guys, I'm working on an image resizer, to create thumbnails for my page. The resizer works on principle of include a DIRECT link to the image. But what I want to do is put in the PHP Variable in the URL string, so that it points to that file and resizes it accordingly. My code is as follows : <img src="thumbnail.php?image=<?php echo $row_select_property['image_url']; ?> Image Resize : <?php // Resize Image To A Thumbnail // The file you are resizing $image = '$_GET[image_url]'; //This will set our output to 45% of the original size $size = 0.45; // This sets it to a .jpg, but you can change this to png or gif header('Content-type: image/jpeg'); // Setting the resize parameters list($width, $height) = getimagesize($image); $modwidth = $width * $size; $modheight = $height * $size; // Creating the Canvas $tn= imagecreatetruecolor($modwidth, $modheight); $source = imagecreatefromjpeg($image); // Resizing our image to fit the canvas imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); // Outputs a jpg image, you could change this to gif or png if needed imagejpeg($tn); ?> What I am trying to do is pass on the variable "image=<?php echo $row_select_property['image_url']; ?>" to the Thumbnail script. At the moment I am passing it through the URL string, but it doesnt seem to load the graphic. I'll try expand on this more, should you have questions as I am finding it a little difficult to explain. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/225718-passing-an-variable-from-one-php-file-to-another/ Share on other sites More sharing options...
litebearer Posted January 26, 2011 Share Posted January 26, 2011 have you tested the value of $row_select_property['image_url']? Link to comment https://forums.phpfreaks.com/topic/225718-passing-an-variable-from-one-php-file-to-another/#findComment-1165406 Share on other sites More sharing options...
stublackett Posted January 26, 2011 Author Share Posted January 26, 2011 Yeah, It's propertyimages/picture1.jpg Link to comment https://forums.phpfreaks.com/topic/225718-passing-an-variable-from-one-php-file-to-another/#findComment-1165419 Share on other sites More sharing options...
litebearer Posted January 26, 2011 Share Posted January 26, 2011 perhaps this? <a href="thumbnail.php?image=<?php echo $row_select_property['image_url']; ?>"><img src="<?php echo $row_select_property['image_url']; ?>" alt=""></a> Link to comment https://forums.phpfreaks.com/topic/225718-passing-an-variable-from-one-php-file-to-another/#findComment-1165423 Share on other sites More sharing options...
PaulRyan Posted January 26, 2011 Share Posted January 26, 2011 You are using $image = '$_GET[image_url]'; I'm pretty sure that won't retrieve the GET value from the URL. Try using $image = $_GET['image_url'];, try this and see if it is the issue. Regards, PaulRyan. Link to comment https://forums.phpfreaks.com/topic/225718-passing-an-variable-from-one-php-file-to-another/#findComment-1165424 Share on other sites More sharing options...
stublackett Posted January 26, 2011 Author Share Posted January 26, 2011 You are using $image = '$_GET[image_url]'; I'm pretty sure that won't retrieve the GET value from the URL. Try using $image = $_GET['image_url'];, try this and see if it is the issue. Regards, PaulRyan. Tried that Cheers Paul, Wasnt correct but put me on the right root. I needed... $image = $_GET['image']; Solved, Thanks Link to comment https://forums.phpfreaks.com/topic/225718-passing-an-variable-from-one-php-file-to-another/#findComment-1165425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.