Jump to content

[SOLVED] How do I do <img src="picture.php?string=123">


bkswindell

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.