bkswindell Posted May 2, 2007 Share Posted May 2, 2007 How do I do <img src="picture.php?string=123">... Right now all i get is a bunch of gibberish. The image is created in php gd. Thanks. picture.php <?php header('content-type: image/jpeg'); $image = imagecreatefromgif('emp.gif'); $size = getimagesize('emp.gif'); $strings = $_GET['strings']; $len = strlen($strings); $cur = 0; $characterarray = array(); while($cur < $len){ $char = $strings{$cur}; array_push($characterarray,$char); $cur = $cur + 1; } /* "*---*" " --" */ $car1 = imagecreatefromgif($characterarray[0].'.gif'); $car2 = imagecreatefromgif($characterarray[1].'.gif'); $car3 = imagecreatefromgif($characterarray[2].'.gif'); $car4 = imagecreatefromgif($characterarray[3].'.gif'); $car5 = imagecreatefromgif($characterarray[4].'.gif'); $car6 = imagecreatefromgif($characterarray[5].'.gif'); $car7 = imagecreatefromgif($characterarray[6].'.gif'); $car8 = imagecreatefromgif($characterarray[7].'.gif'); $dest_x = 17; $dest_y = 33; $dest_x1 = 17; $dest_x2 = 43; $dest_x3 = 69; $dest_x4 = 95; $dest_x5 = 121; $dest_x6 = 147; $dest_x7 = 173; $dest_x8 = 199; imagecopymerge($image, $car1, $dest_x1, $dest_y, 0, 0, imagesx($car1), imagesy($car1), 100); imagecopymerge($image, $car2, $dest_x2, $dest_y, 0, 0, imagesx($car2), imagesy($car2), 100); imagecopymerge($image, $car3, $dest_x3, $dest_y, 0, 0, imagesx($car3), imagesy($car3), 100); imagecopymerge($image, $car4, $dest_x4, $dest_y, 0, 0, imagesx($car4), imagesy($car4), 100); imagecopymerge($image, $car5, $dest_x5, $dest_y, 0, 0, imagesx($car5), imagesy($car5), 100); imagecopymerge($image, $car6, $dest_x6, $dest_y, 0, 0, imagesx($car6), imagesy($car6), 100); imagecopymerge($image, $car7, $dest_x7, $dest_y, 0, 0, imagesx($car7), imagesy($car7), 100); imagecopymerge($image, $car8, $dest_x8, $dest_y, 0, 0, imagesx($car8), imagesy($car8), 100); imagejpeg($image); $filename = $characterarray[0].$characterarray[1].$characterarray[2].$characterarray[3].$characterarray[4].$characterarray[ 5].$characterarray[6].$characterarray[7].".jpg"; if (is_file($filename)) { readfile($filename); exit; } imagejpeg($image,$filename); imagedestroy($image); imagedestroy($car1); imagedestroy($car2); imagedestroy($car3); imagedestroy($car4); imagedestroy($car5); imagedestroy($car6); imagedestroy($car7); imagedestroy($car8); ?> Link to comment https://forums.phpfreaks.com/topic/49727-solved-how-do-i-do/ Share on other sites More sharing options...
Moon-Man.net Posted May 3, 2007 Share Posted May 3, 2007 you will need to include the full URL to the page, eg http://somesite.com/picture.php?string=123 in your img = src tags. -- Nathan Link to comment https://forums.phpfreaks.com/topic/49727-solved-how-do-i-do/#findComment-243907 Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 So like when you go to picture.php you see gibberish? You don't see English text or anything, just gibberish (like if you opened an image in notepad)? That most likely means that the header isn't processing correctly. As for why it wouldn't work correctly in an img tag, I have no idea.... Link to comment https://forums.phpfreaks.com/topic/49727-solved-how-do-i-do/#findComment-243915 Share on other sites More sharing options...
Ravo Posted May 3, 2007 Share Posted May 3, 2007 I agree with Corbin. I used to do that all the time and incorrect headers will completely kill the whole image. Link to comment https://forums.phpfreaks.com/topic/49727-solved-how-do-i-do/#findComment-243928 Share on other sites More sharing options...
SkyRanger Posted May 3, 2007 Share Posted May 3, 2007 I don't know much about image headers but wouldn't this be the problem: header('content-type: image/jpeg'); shouldn't it be: header('content-type: image/gif'); If he is trying to process a gif image and not a jpg or jpeg image Link to comment https://forums.phpfreaks.com/topic/49727-solved-how-do-i-do/#findComment-243930 Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 You can make any kind of image from any kind of image in PHP, and he's out putting a jpeg. imagejpeg($image); It might have something to do with the "content-type", but I don't think headers are case-sensitive... Link to comment https://forums.phpfreaks.com/topic/49727-solved-how-do-i-do/#findComment-243932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.