Glenskie Posted March 27, 2014 Share Posted March 27, 2014 I am trying to set variables with $_GET from the url... caption.php?image=53348b3068f36.jpg&topcaption=sdfas&bottomcaption=asdfadf if (isset($_GET['image'])){ $picture = $_GET['image']; $topcaption = $_GET['topcaption']; $bottomcaption = $_GET['bottomcaption']; Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 27, 2014 Share Posted March 27, 2014 So? What happens? How do you know you have a problem? Turn on error checking to see if you any errors. Quote Link to comment Share on other sites More sharing options...
Glenskie Posted March 27, 2014 Author Share Posted March 27, 2014 i just goes blank with a broken image... i think its because i set the content type as image/jpeg Quote Link to comment Share on other sites More sharing options...
Glenskie Posted March 27, 2014 Author Share Posted March 27, 2014 <?php error_reporting(E_ALL); ini_set('display_errors', '1'); //Set the Content Type header('Content-type: image/jpeg'); if (isset($_GET['image'])){ $picture = $_GET['image']; $topcaption = $_GET['topcaption']; $bottomcaption = $_GET['bottomcaption']; // Create Image From Existing File $jpg_image = imagecreatefromjpeg("../useruploadedphotos/$picture"); // Allocate A Color For The Text $white = imagecolorallocate($jpg_image, 255, 255, 255); // Set Path to Font File $font_path = 'fonts/Timeless-Bold.ttf'; // Set Text to Be Printed On Image $text = "$topcaption"; // Print Text On Image imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text); imagejpeg($jpg_image, "../photos/$picture"); imagejpeg($jpg_image, "../useruploadedphotos/$picture"); imagejpeg($jpg_image); // Clear Memory imagedestroy($jpg_image); // header("location: success.php"); } else{ die('eror'); } ?> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 27, 2014 Share Posted March 27, 2014 I am not familiar with the graphics functions of php. I don't see any output in the above script. Where do you actually send something out to the client? Quote Link to comment Share on other sites More sharing options...
Ansego Posted March 28, 2014 Share Posted March 28, 2014 (edited) ginerjm: I am not familiar with the graphics functions of php. I don't see any output in the above script. Where do you actually send something out to the client? I am not familiar with the graphics functions of php. I don't see any output in the above script. Where do you actually send something out to the client? This needs fix (error): - echo your errors as well for debugging. die('eror'); And add this to the top of your page <?php ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL); ?> Edited March 28, 2014 by Ansego Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 28, 2014 Share Posted March 28, 2014 at a minimum, you need to move the header('Content-type: image/jpeg'); statement down so that it is right above the imagejpeg($jpg_image); line. by outputting the header() first, any php or application error messages are treated as part of the binary image data. i also notice that you are saving the image to two different files. if your intent is to save the image, why are you outputting it to the browser using the header(); and imagejpeg($jpg_image); statements? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.