davidcriniti Posted April 12, 2013 Share Posted April 12, 2013 Hi, I'm just after someone to point me in the right direction on this one, because I'm not sure how to go about it at all. Let's say I've got a table called "tbl_badges" with data regarding badges that will be given to students based on their scores in a quiz. Is it possible to pull the data from the 'badge_name' field and superimpose it on an image. Ie: So badges would essentially look the same, but with different text on the same image. The reason I'm after this solution is to enable non-tech saavy teachers to be able to create a badge by simply filling in a form which asks for a badge name. To give you a visual on what I mean, see the image below. While I've obviously created this myself, I'd like this to be created by "Roman Numerals Badge" being pulled from the badge_name field in the tbl_badges. Anyway, just after some basic direction on what methods I need to investigate to achieve this. Thanks, Dave Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/ Share on other sites More sharing options...
wright67uk Posted April 12, 2013 Share Posted April 12, 2013 Could you use the badge as a background image, and then simply echo your returned variable over the image? Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/#findComment-1424323 Share on other sites More sharing options...
jcbones Posted April 12, 2013 Share Posted April 12, 2013 Yes you can. There are a lot of functions for this, and a lot of different directions you could go. The best place to start would be a tutorial, the available functions are Here! Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/#findComment-1424399 Share on other sites More sharing options...
davidcriniti Posted April 12, 2013 Author Share Posted April 12, 2013 Thank you both, I'll explore all of those options. Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/#findComment-1424438 Share on other sites More sharing options...
Barand Posted April 12, 2013 Share Posted April 12, 2013 (edited) Use plain badge as a background image Process each line of text at a time Use imagettfbbox() to calulate the width of the text so you can centre it Output text at calculated position using imagettftext() Edited April 12, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/#findComment-1424446 Share on other sites More sharing options...
davidcriniti Posted April 12, 2013 Author Share Posted April 12, 2013 Thanks Barand. Just to clarify, when you say "Process each line of text at a time" do you mean that my form for the teachers to submit their badge names (and consequently the table tbl_badges) should have a few fields? ...: (badge_line_1 , badge_line_2, badge_line_3 for example ? Cheers, Dave Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/#findComment-1424453 Share on other sites More sharing options...
Barand Posted April 12, 2013 Share Posted April 12, 2013 That would be easier than parsing the string into lines of suitable width. Or a text area with line breaks. Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/#findComment-1424462 Share on other sites More sharing options...
jcbones Posted April 12, 2013 Share Posted April 12, 2013 (edited) Nevermind, answered. Edited April 12, 2013 by jcbones Quote Link to comment https://forums.phpfreaks.com/topic/276852-superimposing-values-from-mysql-table-onto-images/#findComment-1424463 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.