Jump to content

Archived

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

digi duck

displaying image on html page????

Recommended Posts

Hi, i have a site (http://gamesigs.co.uk) where people create images with custom text on top. The image that is created goes to it's own php page and has a long url such as:

[code]http://gamesigs.co.uk/creation.php?color=30&name=josh=75&y=200&angle=0&font=10&size=25&select=255,255,255&color_r=255&color_g=255&color_b=255&submit=Create+My+Sig![/code]

This changes depeding on what settings you give the text.

What i would like to do is to show this image on a html page. I cant specify a html header because i need to use a jpeg header. I think what i need to do is to give the url a name which is the same despite the differences in it and then put this name in a <img src> tag. How would this be done?

Another way i thought of was by doing something along these lines:

[code]<img src="http://gamesigs.co.uk/creation.php?<?php echo $_POST['color','name',etc...]?>">  [/code] 

Would this work and how should it look???

Here is the code i've been using:

[code]<?php
header("Content-type: image/jpeg");

$name = stripslashes($_GET['name']);

$size = stripslashes($_GET['size']);

$centre = stripslashes($_GET['centre']);

$font = 'images/sig_maker/fonts/'.stripslashes($_GET['font']).'.ttf';

$fontcolor['r'] = stripslashes($_GET['color_r']); // font color - RED

$fontcolor['g'] = stripslashes($_GET['color_g']); // font color - GREEN

$fontcolor['b'] = stripslashes($_GET['color_b']); // font color - BLUE

$lines = stripslashes($_GET['lines']);

function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color){
///

}

if(is_numeric($_GET['color']) && $_GET['color'] >= '1' && $_GET['color'] <= '47')
{
    $bgpic = 'images/sig_maker/' . $_GET['color'] . '.jpeg';
}


$im = imagecreatefromjpeg($bgpic);

//Calculate, the centre:

for(;;){

list($image_width, $image_height) = getimagesize($bgpic);
list($left_x, , $right_x) = imagettfbbox($size, 0, $font, $name);
$text_width = $right_x - $left_x;
if($image_width > $text_width+5){

break;

}

$size = $size - .5;
if($size == 1){
die('Script not responding to decreasing font size, in other words: try using less letters.');
}

}
$hpadding = ($image_width - $text_width)/2;
$vpadding = ($image_height/2)+18;

$textcolor = imagecolorresolve($im, $fontcolor['r'], $fontcolor['g'], $fontcolor['b']);
if($centre== 'y'){

imagettftext($im, $size, 0, $hpadding,$vpadding, $textcolor, $font, $name);

}else{

imagettftext($im, $size, $angle, $x, $y, $textcolor, $font, $name);

}

imagegif($im);
imagedestroy($im);
?>[/code]

Thanks for your help

Share this post


Link to post
Share on other sites
[code]<img src="http://gamesigs.co.uk/creation.php?color=30&name=josh=75&y=200&angle=0&font=10&size=25&select=255,255,255&color_r=255&color_g=255&color_b=255&submit=Create+My+Sig!">[/code]

Orio.

Share this post


Link to post
Share on other sites
You're on the right track.

You just assemble the request string depening on $_POST varaibles.

<?php echo $_POST['color','name',etc...]?>

Won't work though.

I'd say something more along the lines of this:

[code]<?php
echo '<img src="http://gamesigs.co.uk/creation.php?color='.$_POST['color'].'&name='.$_POST['name'].'" />';
?>[/code]

Share this post


Link to post
Share on other sites
Here's an idea: use an associative array in your form to store img properties and values:

[code]<?php
foreach($_POST['imgprops'] as $prop=>$value){
$uriArr[]= $prop.'='.$value;
}
$uri = 'http://gamesigs.co.uk/creation.php?'.implode('&',$uriArr);
?>
<form id="form1" name="form1" method="post" action="">
  <label>name
  <input type="text" name="imgprops[name]" />
  </label>
  <label>color
  <input type="text" name="imgprops[color]" />
  </label>
  <p>
    <input type="submit" name="Submit" value="Submit" />
  </p>
</form>[/code]

A lot of people don't realize you can use associative arrays for get and post index values.

Get example:
[u][i]?imgprops[color]=blue&imgprops[name]=image1&create=true[/i][/u]

[i]print_r($GET)[/i] now prints:
[quote]Array
(
    [imgprops] => Array
        (
            [color] => blue
            [name] => image1
        )

    [create] => true
)[/quote]

Share this post


Link to post
Share on other sites

×

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.