Jump to content

[SOLVED] PHP GD Help


jnerotrix

Recommended Posts

Hello I have a my ID Card generator Almost finished but there is one thing i need help with

 

The text only appears on the bottom right of the image

I need to make the text appear in a specific spot what is the code for that here is the current code:

 

 

<?php

$user = $_POST['user'];
$img = $_POST['picture'];

header ("Content-type: image/png");
$string = $user;
$font = 4;
$width = imagefontwidth($font) * strlen($string);
$height = imagefontheight($font);
$im = imagecreatefrompng($img);
$x = imagesx($im) - $width;
$y = imagesy($im) - $height;
$backgroundColor = imagecolorallocate ($im, 255, 255, 255);
$textColor = imagecolorallocate ($im, 0, 0, 0);
imagestring ($im, $font, $x, $y, $string, $textColor);
imagepng($im);

?>

Link to comment
https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/
Share on other sites

Ok i simplified it and now i get an error and after the error lots of weird symbols

 

Here is the error:

Warning: Cannot modify header information - headers already sent by (output started at /www/110mb.com/c/u/s/t/o/m/-/a/custom-art/htdocs/idcard/generatred.php:2) in /www/110mb.com/c/u/s/t/o/m/-/a/custom-art/htdocs/idcard/generatred.php on line 15

 

This is After The Error: (Its to long to write put it all)

 

‰PNG  ��� IHDR��T���Ø���;õŒõ�� �IDATxœì½k\çyø<ïwnÝ=Óƒ+/Z’­ØÐIl+[†#;Zz‹ˆ¥¬”õB[å­e¬‚k³›RÅÁÞRf¹LÿqÑë‚«¶R‹¢“8Ö1£ªÔ ›„»Ñ´EYrlÈk9²,´d[²I–�Ó3ÓÝçò½Ïþøzší$.ÙÏàôéÓÝçœ9ïýyß’°ÄK¼þ`wú–Xb‰;ƒ¥ð/±ÄëÙ|‹€+ƒ€´?añÝÅýWýàK,ñjÆÌòï’ä9æ!Éöü°Åý»ÞZb‰%î ®Cò…|.óW¾µÄKÜÈðÒ¢{ýžüK…K,±Ä«Ù·>dW•ð¹ÊXJþKÜ]¸ÞlÿKÙöeÌ¿Äw)®Kø¿¥W¿”ÿ%–¸ëð­…Ï/±ÄkßBø¯Qü_´óK±Äw(é¥òü/åÆ_õÝ¥ä/±ÄÝ.{–Xâõ‰%·‰%^§X ÿK¼N±þ%–xâ~s¼å-o¹éç±Ä¯yHʲì¾ûî[]]½=¹¶|à×xwiù—Xâö¡ëºíííc–e�Hæy^E–ef7G:tG¾Ë¿ÄK\?ÌŒd–eY–IŠ1–e¹ººjfîB(Š¢( ’—.]ºtéÒ+ü¹sçÎ]ç‘Ká_b‰›3+Š"Ïóô2„d»ª*!�BfÖuÝt2麮išªªÞðÆ7Þ{ï½1Æä܆³] ÿK\o}ë[üÇü}ï{ßsÏ=÷-!¬®®&¾¬*ɇïbŒ]g¤¤ÑåË“ñ.÷Xäy¯×#ùƒo}«Kûß

 

This is the New Code I wrote:

<?php

$user = $_POST['user']; // Gets The User Name (Working)
$img = $_POST['picture']; // Gets The Image Style Chosen in Form (Working)

$string = $user; //  This is The Displayed Text From The Form (Working)

$im = imagecreatefrompng($img); // This Loads The Image Style From The Form
$bg = imagecolorallocate ($im, 255, 255, 255); // This is Kinda Pointless Its a Loaded Style Image (Working)
$textColor = imagecolorallocate ($im, 0, 0, 255); // This is the Text Color (Working)
imagestring($im, 5, 0, 0, $string, $textColor); // This Puts Everything Together including Text Location (Working)


header('Content-type: image/png'); // This Displays The Image (THIS IS GIVING AN ERROR) Line 15

imagepng($im); // Not Sure What this Does 
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/#findComment-674583
Share on other sites

Ok I Figured it Out Myself after Countless Hours of research Thanks for the Help if any1 is intersted here is how i fixed it:

 

<?php

$user = $_POST['user'];
$img = $_POST['picture'];

$string = $user;
$im = imagecreatefrompng($img);

$textColor = imagecolorallocate ($im, 0, 0, 0);
imagestring($im, 80, 60, 85, "$string", $textColor);

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

imagepng($im);

?>

Link to comment
https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/#findComment-674632
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.