Jump to content

Image creation/text addition help


DaveLinger

Recommended Posts

[code]<?php

$template = $_GET['template'];

$nametext = $_GET['nametext'];
$namefont = $_GET['namefont'];
$namecolor = $_GET['namecolor'];

$subtitle = $_GET['subtitle'];
$subfont = $_GET['subfont'];
$subcolor = $_GET['subcolor'];

// Set the content-type
header("Content-type: image/png");

// Create the image
$im = imagecreatefrompng('$template');

// Create some colors
switch ($namecolor)
{
  case "black":
    $ncolor = imagecolorallocate($im, 0, 0, 0);
    break;
case "white":
    $ncolor = imagecolorallocate($im, 255, 255, 255);
    break;
}

switch ($subcolor)
{
  case "black":
    $scolor = imagecolorallocate($im, 0, 0, 0);
    break;
case "white":
    $scolor = imagecolorallocate($im, 255, 255, 255);
    break;
}

// Add the text
imagettftext($im, 20, 0, 23, 20, $ncolor, $namefont, $nametext);
imagettftext($im, 12, 0, 23, 120, $scolor, $subfont, $subtitle);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>[/code]

yields "The image “http://www.davessonicsite.com/sig/signature.php?template=shadow1.png&nametext=[PCR]Davers&namefont=Verdana.ttf&namecolor=black&subtitle=I%20pwn%20n00bs&subfont=Verdana.ttf&subcolor=black” cannot be displayed, because it contains errors."

shadow1.png and Verdana.ttf are in the same folder as signature.php... any ideas?
Link to comment
https://forums.phpfreaks.com/topic/15159-image-creationtext-addition-help/
Share on other sites

[code]<?php
$im = imagecreatefrompng('$template');
//Change to...
$im = imagecreatefrompng($template);
//Or...
$im = imagecreatefrompng("$template");
//Because...
$foo = "bar";
echo $foo;  //Displays "bar"
echo "$foo"; //Displays "bar"
echo '$foo'; //Displays "$foo"
?>[/code]

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.