jnerotrix Posted October 25, 2008 Share Posted October 25, 2008 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 More sharing options...
Stephen Posted October 25, 2008 Share Posted October 25, 2008 You just edit the x and y coordinates in imagestring. Link to comment https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/#findComment-674557 Share on other sites More sharing options...
jnerotrix Posted October 25, 2008 Author Share Posted October 25, 2008 how its connected String to string to string ??? What Do i Edit $x = imagesx($im) = $im = imagecreatefrompng($img) -- $img = $_POST['picture']; What do i edit for the X & Y Coordinates Link to comment https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/#findComment-674559 Share on other sites More sharing options...
Barand Posted October 25, 2008 Share Posted October 25, 2008 For example, to centre the text, divide your current x and y values by 2 Link to comment https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/#findComment-674560 Share on other sites More sharing options...
jnerotrix Posted October 25, 2008 Author Share Posted October 25, 2008 I am a php newb how do i divide it by 2 im sorry to be difficult Link to comment https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/#findComment-674562 Share on other sites More sharing options...
jnerotrix Posted October 25, 2008 Author Share Posted October 25, 2008 $x = imagesx($im) - $width; $y = imagesy($im) - $height; Is this what i need to edit and if so then how Link to comment https://forums.phpfreaks.com/topic/130097-solved-php-gd-help/#findComment-674569 Share on other sites More sharing options...
jnerotrix Posted October 25, 2008 Author Share Posted October 25, 2008 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 More sharing options...
jnerotrix Posted October 25, 2008 Author Share Posted October 25, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.