Jump to content

Creating PNG File


steveangelis

Recommended Posts

<?PHP 
$alias=$_POST['alias'];
$rank=$_POST['rank'];
$enlist=$_POST['enlist'];
$team=$_POST['team'];
$fleet=$_POST['fleet'];
$ship=$_POST['ship'];

header("Content-type: image/jpeg");

$font = 'arial.ttf';   

  $im = imagecreatefrompng('700x200blanc.png');
  $textcolor = imagecolorallocate($im, 255,255,255);
  imagettftext($im, 12, 0,20, 35, $textcolor, $font, $alias);
  imagettftext($im, 12, 0,20, 21, $textcolor, $font, $rank);
  imagettftext($im, 12, 0,50, 125, $textcolor, $font, $fleet);
  imagettftext($im, 12, 0,50, 50, $textcolor, $font, $team);  
  imagettftext($im, 12, 0,50, 100, $textcolor, $font, $enlist); 
  imagettftext($im, 12, 0,100, 20, $textcolor, $ship, $enlist); 
  // output the image
$newname="$alias.png"; 
   imagejpeg($im,$newname);


  ImageDestroy ($im);
?>
<html>


<p style="text-indent: 0; line-height: 100%"><b><a href="<?PHP echo $newname;?>"><?PHP echo $newname;?></a>
</b></p>

<p style="text-indent: 0; line-height: 100%"> 
</p>
<p style="text-indent: 0; line-height: 100%">  
                    
</p>
</body>
</html>

I am trying to save the image as a .png file because I need to keep the transparency of it but it does not work.  It saves with a black background.  Also, $ship is coming from a variable which is another png image to which I am trying to put onto this image but it is not working.  Does anyone know why?

Link to comment
https://forums.phpfreaks.com/topic/161578-creating-png-file/
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.