New
Dec 15, 2008 11:53 AM
#1
Tutorial: Generating images using php and the MAL-RSS-feed Before the show starts: This is my first tutorial on php-programming so bare with me if its (maybe) sometimes hard to understand or not really clear what i try to say. So...if you have any questions about this tut or you have any ideas how to improve it let me know. Improvements can never be a bad thing. 1.Starting notes 2.Requirements 3.Setting up the script 4.Vital source-code parts in detail 5.Creatin your own customized signature 6.Additional information 7.Possible errors and how to handle them Full source files of this tutorial you will need: download (be sure to keep the given structure intact when you upload the files to your webspace) [when you unzipped the source, uploaded it, and made everything correct you should get an output according to the one you see below) This tutorial is for those of you, who want a scripted signature that uses a non-MAL custom font. An example how it can look like: ![]() 1. Starting notes The script we will make during this tutorial is neither the best, nor the last answer on how to create a scripted signature. There are more advanced scripts out there, which do more than just the basic things provided by this tutorial. Nevertheless you will be able to make a working, customizable scripted signature that can easily be upgraded with more functions. For more advanced script try taking a look at the „Signature Scripters“ Club (http://myanimelist.net/clubs.php?cid=5076). If something is unclear, or you just don't know how to do a certain step feel free to post below. Suggestions and criticisms are also welcome. 2. What you will need to successfully pass this tutorial:
Plusses to have on your side: basic knowledge of webdesign and or php-programming (this is not a 'need to have'); basic knowledge of ftp-clients or how to upload files on a webserver and how to alter chmod of files So, if your still here, then you are seriously interested in how to script your own flashy signature. Thats good! Lets start then. First of all, you will need a signature graphic that you like. So go on and choose one. Come back to this tutorial if you have done so. 3. Setting up the script I will take you step by step through the setup process. To start with, download the zip file from the link above and extract it. Here's the link once more: download Fire up your ftp-client and upload all the files to your webspace. It is very important that you keep the given file-structures intact. This done, set the following chmods:
(Note:with a standard ftp-client you can change a files/folders chmod like that: right click on a file or folder, choose 'chmod' in the appearing contextmenu.The rest should be self-explanatory) Open a browser of your choice and open the url: 'yoursite.com/signature/sig_creator.php' If your host matches all requirements, and you have done everything right, you should see something like my actual signature. Congratulations!! You have taken the first steps in creating a custom signature... Before we start with creating your own personalized sig, we have to do some more homework. Let's get started.... 4. Vital source-code parts in detail If you open the spoiler-tag you will see some source-code of the sig-script we're using right now. Cause it is vital for you to understand this part of the script to generate your own custom sigs, i will explain it in detail. $blub = ImageCreateFromPng("your_pic.png"); $font = 'Capture_it'; $colour = imagecolorexact($blub,0,0,0); imagefttext($blub,14,0,118,48,$colour,$font,$titles[0]); imagefttext($blub,12,0,170,60,$colour,$font,$status[0]); imagepng ($blub);
5. Creating your own customized signature I guess right now, you have chosen, the gfx you want to use as a signature. If not, do so now and come back when your done with that. As before, i will take you step by step through the whole process. Due to the fact, that we have to change the source code, you will have to open the file 'sig_creator.php' in any texteditor you like. Next you have to find the part that looks like this:
Now: replace ("your_pic.png") with the name of the sig-gfx you'd like to use e.g. if the png you want to use is called „flashy.png“ you would have to change ("your_pic.png") to ("flashy.png"). [easy isn't it ^^] For now, leave the rest as it is. Save the file and upload the changed 'sig_creator.php' and your sig-gfx to your webspace. For information on how to change the font or how to make more than one anime title appear on your sig read point 4. If you're satisfied with the outcome there is merely one thing left. Once again open the file 'sig_creator.php' in any texteditor you like. Find the following line:
Save the file. Once again. Upload the file 'sig_creator.php' to your webspace. Browse to 'yoursite.com/signature/sig_creator.php'. If you get an error like „The Image „your-image“ cannot be displayed because it contains errors“ don't start to panic. Instead open the following url: 'yoursite.com/signature/sig.png' If you get an output everything worked fine. If you have chosen to save the png-output of the sig-creation process, and you want to use this saved png-file instead of the raw 'php-site' as your sig you have to do one more thin. (read under point 4 how to save the png-output) That is to automate the update of your signature. Read under point 6: cronjob, how to achieve this. 6. More Information on how to setup the serverside direcotories and how to automate the sig-generating process
7. Possible errors and how to handle them Error: The Image „your-image“ cannot be displayed because it contains errors Solution: Thats not really a problem. The output png should have been compiled correctly. Error: There is no output png saved. Solution: Upload a file with the same name you defined for your output png. E.g. if you named it 'sig.png' upload a file 'sig.png' and start the script once more. Make sure the files chmod is set to 755. Error: There is a png output, but no information appears on it. Solution: Check if your hoster allows 'allow_url_fopen'. Must be set to 'on'. You can check this in the phpinfo. Error: I get a weird looking php error. Solution: Make sure the file 'sig_creator.php' has its chmod set to 755 |
ehrgeizDec 19, 2008 1:38 PM
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Dec 15, 2008 12:32 PM
#2
Good tutorial. It should get most interested people on the right track. I have a few suggestions and comments.
|
Dec 16, 2008 9:50 AM
#3
Dec 17, 2008 6:23 AM
#4
although I am php retarded, this looks like a great tutorial. Way to go; we need more of those well...i hope this tutorial will help interested people in creating their own custom sigs. I think it's definitely a good start and some helpfull information to begin with. No one starts scripting at the top notch. Everyone has to learn how to do it. @kuroshiroi: thanks for your information |
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Dec 17, 2008 7:08 AM
#5
Your post is very much appreciated. I've been meaning to fool around with this stuff some, and it's ever so nice not to have to start from scratch. |
![]() |
Dec 18, 2008 7:54 AM
#6
Just thought I'd add an observation after spending a while tweaking the script for my own signature: the script needs more comments. I'm bad about adding them in my own code, but they're extremely helpful when digging through someone else's, and for something like this where the intent is for people who know less than you about programming (perhaps even very little) or at least aren't familiar with the specifics of parsing RSS feeds and image generation and such to get in and mess with things and learn from it, comments in the code are pretty critical. I managed just fine myself and am very grateful for the assistance, but I imagine with less programming experience I would've had trouble. |
![]() |
Dec 18, 2008 11:50 AM
#8
@krelian: thanks for your reply and sharing your thoughts The improvement of this tutorial depends on such statements and replies. I will add more and better comments as soon as possible. |
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Dec 18, 2008 9:10 PM
#9
Thanks a lot for this :D It is very helpful. I started learning php recently so I had the basics with me. I will surely make my siggy out of this, it is all neat and simple. Also, like krelian said, putting more comments in the code will totally help (someone like me :P who is quite new to this) especially to the part where you prepare the parsed info for the signature :D this will surely help get better understanding of it. |
Dec 18, 2008 9:53 PM
#10
Dec 19, 2008 12:39 PM
#11
I made one :D Just one thing in the code, I guess is not that big deal and I know it doesn't have any effect, but that last comment you added, for the imagedestroy function, the variable you kept in brackets, shouldn't it be the same variable you declared for holding the image? i.e. ($blub) |
NotADoctor_Dec 19, 2008 12:43 PM
Dec 19, 2008 1:39 PM
#12
Fara7 said: for the imagedestroy function, the variable you kept in brackets, shouldn't it be the same variable you declared for holding the image? i.e. ($blub) that's right...don't know what i thought while writing this ^^ fixed it - thanks for the hint and a nice sig Fara |
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Dec 22, 2008 3:03 AM
#14
Dec 22, 2008 4:54 AM
#15
Yep. You can basically just copy the code that reads the title and then change the variables (you'll need a new array and a counter variable as well, initialized at 0 like the others). Also, if you want to format the date differently than MAL does, you could use strtotime to convert it to a Unix timestamp and then strftime to output a string in whatever format you like. |
![]() |
Dec 22, 2008 10:10 AM
#16
I tried it and it didn't work :( I declared the variable that will hold the date and also the counter value. I copied the part which fetches the titles and made the needed changes to the variables but nothing worked. Whenever I load the picture I don't get any dates. I guess I shouldn't be working with this right now since tomorrow I have an Informatics practical test in Visual Basic and PL/SQL :P.....this will get me confused between syntaxes, I already get confused between VB and PL/SQL..... |
Dec 22, 2008 10:36 AM
#17
Hah, yeah, I always get a little mixed up on syntax too between different languages (which is why it's so handy to have the internet around, though I don't guess that helps in a test environment). Anyway, here's what I did: $date = "<pubDate>"; added to the variable declarations at the top, and for ($j=1;$j<$i;$j++) { right after the loop that goes through the titles. That'll give you a dates array to use at the end. You'll probably want to check the specifics of strftime so you can change that format string ("%d %B %Y") to whatever suits you |
![]() |
Dec 22, 2008 11:56 AM
#18
Oh thanks a lot for that :) It works now. Actually I realized what was the mistake I made before. When I assigned <pubDate> to $date, I forgot to check if the case matched what was given in the RSS file and wrote it as <pubdate>.....oh well, I always tend to do such silly mistakes and get stuck trying to find where I went wrong xD |
Dec 24, 2008 5:12 PM
#19
Its really really late here 3:15 pm so i have to sleep. But i wanted a tytorial like this so bad that i was thinking of starting a thread :P Really thanks with a quickglance it seemed really nice.Ill comment again after i make my sig tommorow. EDIT: I made an account at the website you suggested and it worked perfect. But after 2-3 my sig was gone. I accessed the website and saw that " Website is under maintenance it will be back in 2-4 hours". 6 hours passed and still no sig. How aften are these "check ups" ? Any other better free host? Thanks for help |
CloudyDec 25, 2008 12:47 PM
Dec 27, 2008 4:53 PM
#20
I did exactly what the tutoriall said but i keep getting the 500 Internal Server Error when I open the sig_creator.php Yes the folder is chmod to 777 and the two files are at 755. |
subishiroDec 27, 2008 5:11 PM
Dec 27, 2008 5:19 PM
#21
Cloud1234: If you're asking about 000webhost, afaik the checks only happen once. I've been using them for a couple of months now and the only time they checked my site was when it started receiving visitors and never again. Mukyaa: Which host are you using and please post a link the the sig_creator.php so we can see the error output. |
Dec 27, 2008 5:33 PM
#22
[http://tjs.nextgenwebhosting.com/signature/sig_creator.php]My sig_creator.php[/url] I got my hosting from a friend. It has cPanel, 1GB Space and 5GB Monthly Bandwidth. |
Dec 27, 2008 5:45 PM
#23
Try setting the folder to 757, it seems your host doesn't like group writing permissions for some reason. If that doesn't work I've got nothing. Edit: Some googling revealed this to be a likely cause and if this doesn't work you might need to set the permissions to 755. |
Dec 27, 2008 5:47 PM
#24
kuroshiroi said: Try setting the folder to 757, it seems your host doesn't like group writing permissions for some reason. It that doesn't work I've got nothing. Did that and got "Internal Server Error Directory "/home/tjsnext/public_html/signature" is writeable by others" |
Dec 27, 2008 5:48 PM
#25
Hehe, just edited it, try 755. |
Dec 27, 2008 5:51 PM
#26
thanks now it works... just need to make it now EDIT: I made it! Hopefully it's alright as my first sig. Now another question, how do I get the score information from my list? |
subishiroDec 29, 2008 11:16 AM
Dec 30, 2008 4:07 AM
#27
i'm at work right now, so im bound to give you just a short answer (hope it helps anyway) some hints: - you will need several layers:
- you have to merge and copy the layers to get the final image merging can be done with: ImageCopyMerge ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct ) copy-pasting of images is done with: ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) I might make a sequel to this Tutorial where i will explain how to achieve such things like image rotation, multiple layers and advanced text effects. For now you can find an example how to handle multiply layers in KHobbit*s signature script (find it here |
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Dec 30, 2008 6:26 AM
#28
I'm chiming in, since I can hopefully be of some help. I played around with shiteiru's code and basically this is the order you'll want your code to be, I think everything's included: --------------------------------------------------------------------------------------- //generate the image $blub = imagecreatefrompng('bgimg.png'); ------ here be random function for image. ------ //imagecolorexact(image, red(between 0 and 255), green, blue) //imagecolorexact($blub,0,0,0) = black font | imagecolorexact($blub,255,255,255) = white font $colour = imagecolorexact($blub,0,0,0); $font = 'Capture_it.ttf'; //imagefttext(image, font size, angle, x-pos(relative to the image in px), y-pos, font color, fontfile, text output) imagefttext($blub,14,0,118,48,$colour,$font,$titles[0]); imagefttext($blub,12,0,170,60,$colour,$font,$status[0]); // Copy imagecopy($blub, $src, 0, 0, 0, 0, 600, 140); imagepng ($blub); //we want our final image to be in the png format --------------------------------------------------------------------------------------- and then this is the randomizing code, stolen and modified from my own code. --------------------------------------------------------------------------------------- $num = rand(0,2); switch($num) { case 0: $src = imagecreatefrompng ('chie_face.png'); break; case 1: $src = imagecreatefrompng ('chie_chest.png'); break; case 2: $src = imagecreatefrompng ('chie_leg.png'); break; default: $src = imagecreatefrompng ('chie_face.png'); } --------------------------------------------------------------------------------------- It's not fancy but it works and it's plenty for this application. If you want to change something else besides the image, such as font colors and such you can just cut and paste code into the switch as needed. I hope this helps. Edit: I'm actually doing this a little differently though, for instance the Haruhi image in this sig is not two different images, just one that I move around with the y coordinates of imagecopy, so you can probably do something similar using the switch. Unnecessary feature: http://kuroshiroi.net78.net/malsig/kuro.php?sig=haruhi&ver=60 I can even move her around using the url ;) |
kuroshiroiDec 30, 2008 6:37 AM
Dec 30, 2008 7:21 AM
#29
Dec 30, 2008 7:41 AM
#30
Fara7 said: Yup, I actually tried to use select at first but that didn't really work :)So switch() is a conditioning statement. As long as the random number created by rand() equals the number after case, it displays an image. Just like the select statement in VB :) The only real difference is that php's switch needs the break; command to work like select does. That threw me off for a while. |
Dec 30, 2008 5:08 PM
#31
The switch needs to be above this line: imagecopy($blub, $src, 0, 0, 0, 0, 600, 140); and not at the bottom. I should probably have just pasted it together in the right order myself but I thought I would try to show you how the switch works first. I'm surprised you're not getting an error actually :) |
Dec 30, 2008 5:11 PM
#32
At first glance, I'm thinking your problem is that this bit<pre>$num = rand(0,2); Needs to go above this bit <pre>// Copy The former chooses which image to overlay and the latter copies it over and saves out the signature, so if you've got them reversed you're pasting in the overlay image and saving the result before there's anything there. [edit] Looks like I'm too slow to be useful =P |
![]() |
Dec 30, 2008 5:28 PM
#33
Krelian: Nothing wrong with bashing windy over the head with a wall of text :) |
Dec 31, 2008 2:37 AM
#34
Dec 31, 2008 4:30 AM
#35
Ripaz said: Is there any way to limit my output characters? Example: I have "Code Geass - Hangyaku no Lelouch" and I want it to show 15 characters so it should look like this "Code Geass - Han..." The way I normally do this is through the following method:
This doesn't handle the ellipsis, though. But you can handle that easily by changing $substringanime in the second line to something like "$substringanime..." (Note that it needs to be in quotes like any other constant text.) If you'll notice, my current signature is using this technique. The lettering in it is not tracked, but rather every letter you see on it is a substring of 1, and can be individually placed, colored, and moved around however I please. It's a bit more work and lines to add in, but it opens the door a little bit to a few more nontraditional designs. EDIT: Forgot to mention the ellipsis. |
IriDec 31, 2008 5:03 AM
Dec 31, 2008 5:04 AM
#36
the way Iri mentioned is the most easy and straightforward to do it. for my script, there's a really easy way to achieve a cutting for all animetitles with just minimal changes... find this piece of code in the php-file: //now we have to prepare the information we cached in the $buffer array earlier //for this we are going to use a for-loop //this for-loop just extracts the anime_title information for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $titles[$t] = str_replace($end,"",$ncnt); $t++; } } and replace it with this one: //now we have to prepare the information we cached in the $buffer array earlier //for this we are going to use a for-loop //this for-loop just extracts the anime_title information for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $cutter = str_replace($end,"",$ncnt); $titles[$t] = substr($cutter, 0, 15); $t++; } } the rest can stay as it was before the only part that really gets a change is the one i made extra super eye catching with red color be aware that this change influences all animetitle in our array Edit: in depth explanation of the used code
|
ehrgeizDec 31, 2008 5:49 AM
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Dec 31, 2008 7:50 AM
#37
Thanks all, I found this helpful. I was testing it: here. Oh, I have a question, how is it possible to output the titles and status on the same line? I tried this: imagefttext($image,14,0,7,118,$colour,$font,$titles[0].$status[0]); but still, it moves the status to the next line. |
Dec 31, 2008 9:20 AM
#38
Dec 31, 2008 9:58 AM
#39
I was able figure out how to do this but by using one line (not the info from MAL). Here's the very simple code. <?php This is the output: Here.$string = "Code Geass - Hangyaku no Lelouch R2"; If (strlen($string) > 20) { $reqstr = substr($string, 20, strlen($string)); $repstr = str_replace($reqstr, '....', $string); } print $repstr; ?> So something similar has to be done for the titles. Edit: I tried it out on the signature code and guess it is done this way. //prepare the parsed information for the pic for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); $string = str_replace($end,"",$ncnt); if (strlen($string) > 20) { $required = substr($string, 20, strlen($string)); $replace = str_replace($required,"....",$string); } $titles[$t] = $replace; $t++; } } Strlen() - this returns the length of a string. I am not much knowledgeable in php but I hope this was helpful. |
NotADoctor_Dec 31, 2008 10:34 AM
Dec 31, 2008 8:19 PM
#40
Regarding printing the title and status on the same line, that ought to work fine (though you could do with some spaces in there instead of just tacking one string onto the other). I ran into the same problem though - there's a newline character in there that you need to get rid of. The trim function should do the trick nicely there. |
![]() |
Dec 31, 2008 11:55 PM
#41
Jan 1, 2009 3:53 AM
#42
Ok im trying to customize the sig you see i have now. But there are some problems. First of all, as you see i know how to install and use a fond.But the problem is that it works ONLY for "capture_it" and no other. I tried 4-5 different fonts, i uploaded the ttf in the file directory where it should be but still nothing.Why does it work ONLY for "capture it" font? I did everything in the tytorial but still... Secondly, I want my sig to have more than 1 update.I thought that since with this: imagefttext($blub,14,45,10,120,$colour,$font,$titles[0]); imagefttext($blub,13,45,15,137,$colour,$font,$status[0]); I got one if i did this (with different X-pos of course): imagefttext($blub,14,45,10,120,$colour,$font,$titles[0]); imagefttext($blub,13,45,15,137,$colour,$font,$status[0]); imagefttext($blub,14,45,10,120,$colour,$font,$titles[1]); imagefttext($blub,13,45,15,137,$colour,$font,$status[1]); I would get 2 updates... But it doesnt work. My last problem is how to place dots when the anime is too long. For example now Akane doesnt fit in my sig. I want if it crosses the border to end like this: Akane-Iru Ni ... Instead of just going through. I really need some help :( Heres my whole script atm- If someone could tell me what to change or to modify it so that will work i would be glad :3 <?php header("Content-Type: image/png"); //specify the url that shall be read $url = "http://myanimelist.net/rss.php?type=rw&u=Cloud1234"; //generate a readable file out of the specified url for our parser to read $file = @fopen ("$url","r"); //starting and ending strings needed to get the valuable information out of the file //do not modify this unless you know what you are doing $title = "<title>"; $ptw = "<description>Plan to Watch -"; $watching = "<description>Watching -"; $completed = "<description>Completed -"; $onhold = "<description>On-Hold -"; $dropped = "<description>Dropped -"; $titleend = "</title>"; $descend ="</description>"; //set variables $t = 0; $z = 0; //rss-parser(Anime-Titles) if (trim($file) == "") { echo "Service out of order"; //if we can't create a file MAL is supposed to be down } else { $i=0; //this while-loop will run until the end of the file and read it line per line //every single read line will be save in an array (in this case $buffer[$i] while (!feof($file)) { //1024 bytes per line will be read until the end of file has been reached //every single line will be saved in the array $buffer //example: line 1 would be saved in $buffer[0]; line 2 would be saved in $buffer[1] and so on $buffer[$i] = fgets($file,1024); $i++; } fclose($file);//close the file } //now we have to prepare the information we cached in the $buffer array earlier //for this we are going to use a for-loop //this for-loop just extracts the anime_title information for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $titles[$t] = str_replace($end,"",$ncnt); $t++; } } //this for-loop just extracts the anime_episode information for ($j=1;$j<$i;$j++) { //episodes if ($cnt = strstr($buffer[$j],$ptw)) { $status[$z] = "plan to watch"; $z++; } if ($cnt = strstr($buffer[$j],$completed)) { $status[$z] = "completed"; $z++; } if ($cnt = strstr($buffer[$j],$onhold)) { $status[$z] = "on hold"; $z++; } if ($cnt = strstr($buffer[$j],$dropped)) { $status[$z] = "dropped"; $z++; } if ($cnt = strstr($buffer[$j],$watching)) { $ncnt = str_replace($watching, "", $cnt); $end2 = strstr($ncnt, $descend); $status[$z] = str_replace($end2,"",$ncnt); $z++; } } //generate the image $blub = ImageCreateFromPng("Satsukisig.png"); $font = 'Capture_it'; //imagecolorexact(image, red(between 0 and 255), green, blue) //imagecolorexact($blub,0,0,0) = black font | imagecolorexact($blub,255,255,255) = white font $colour = imagecolorexact($blub,0,0,0); //imagefttext(image, font size, angle, x-pos(relative to the image in px), y-pos, font color, fontfile, text output) imagefttext($blub,14,45,10,120,$colour,$font,$titles[0]); imagefttext($blub,13,45,15,137,$colour,$font,$status[0]); imagepng ($blub); //we want our final image to be in the png format //imagepng ($blub, "sig.png") //imagepng (image, save as) //imagedestroy ($blub); ?> |
CloudyJan 1, 2009 4:06 AM
Jan 1, 2009 4:01 AM
#43
What is the extention of the font you are trying to use? If the extension is 'TTF' (in capital letters) it won't work (this happens to me sometimes), so try changing the extension to 'ttf'. For adding dots to long titles, try what I posted 2 posts above this or wait for someone who knows better to give a better way :) |
Jan 1, 2009 4:16 AM
#44
@Fara7: I replaced this code you gave me, but it doesn't show nothing when I put 2 character number. Only works with 1 character numbers. EDIT: I just might know where is problem. I think when title is shorter than for example 20 characters it will not show it. I would fix it but PHP is not my better side. Other than that the rest is working fine. |
RipazJan 1, 2009 4:39 AM
Jan 1, 2009 4:52 AM
#45
@ripaz: to show something like 'Code Geass R2' like 'Code Geass...' you will have to do the following tewaks to the code: find the following code: for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $cutter = str_replace($end,"",$ncnt); $titles[$t] = substr($cutter, 0, 15); $t++; } } and replace it with this: for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $cutter = str_replace($end,"",$ncnt); If (strlen($cutter) > 12) { $titles[$t] = substr($cutter, 0, 12); $titles[$t] .= "..."; } else{ $titles[$t] = str_replace($end,"",$ncnt); } $t++; } } the vital parts are marked in red what it will do: check if a title is longer than 12 characters, if so the loop will be activated, the string will be trimmed and '...' after the 12th character. It is vital that you cut the string after the 12th char cause you want to add 3 dots and get a final counting of 15 to work with. @cloud: imagefttext($blub,14,45,10,120,$colour,$font,$titles[0]); imagefttext($blub,13,45,15,137,$colour,$font,$status[0]); imagefttext($blub,14,45,10,120,$colour,$font,$titles[1]); imagefttext($blub,13,45,15,137,$colour,$font,$status[1]); [/qote] this should work, try to make the y-pos a little smaller e.g. replace 120 with 50 an 137 with 67 and see if it works My last problem is how to place dots when the anime is too long. For example now Akane doesnt fit in my sig. I want if it crosses the border to end like this: Akane-Iru Ni ... see above, thats the same prob ripaz has... to the font-problem if you have something like: $font = 'Your_Font'; try replacing it with: $font = Your_Font.ttf'; note that: the font has to be written case-sensitive; also, if the font has another ending than .ttf you will have to write the font plus the ending in case-sensitive letters like in my example above, otherwise it wont work. |
ehrgeizJan 1, 2009 5:07 AM
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Jan 1, 2009 5:07 AM
#46
Yeah I have done that. Replaced code and now look like this //this for-loop just extracts the anime_title information for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $cutter = str_replace($end,"",$ncnt); If (strlen($cutter) > 32) { $titles[$t] = substr($cutter, 0, 32); $titles[$t] .= "..."; } $t++; } } Sig looks like this: Currently watching Akikan! that has 12 characters in total (with TV suffix). I have set 32 characters to cut but when title is shorter than that it will not show it at all. Dunno if I explained well. |
Jan 1, 2009 5:09 AM
#47
fixed the issue in my above post, realized the problem as soon as i posted the solution... you have to add this part else{ $titles[$t] = str_replace($end,"",$ncnt); } |
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
Jan 1, 2009 5:12 AM
#48
Ok i solved the fond and the 2 updates problem.But the dots just wont show up :3 for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "$titles", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $cutter = str_replace($end,"$titles",$ncnt); If (strlen($cutter) > 6) { $titles[$t] = substr($cutter, 0, 6); $titles[$t] .= "..."; } else{ $titles[$t] = str_replace($end,"$titles",$ncnt); } $t++; } } ?> This is my code what am i doing wrong? This is what i get |
Jan 1, 2009 5:18 AM
#49
try this: for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$j],$title)) { //strstr('string to be searched', 'string to search') //if the specified string has been found do... //str_replace('found string', 'replace with', 'replace it in') //and save it in the variable $ncnt $ncnt = str_replace($title, "", $cnt); $end = strstr($ncnt, $titleend); //strstr('string to be searched', 'string to search') //once again replace a part of the string and save the outcome in a new arrai $cutter = str_replace($end,"",$ncnt); If (strlen($cutter) > 6) { $titles[$t] = substr($cutter, 0, 6); $titles[$t] .= "..."; } else{ $titles[$t] = str_replace($end,"",$ncnt); } $t++; } } |
Luck is the last dying wish of those who wanna believe that winning can happen by accident, sweat on the other hand is for those who know it's a choice, so decide now because destiny waits for no man. |
More topics from this board
» New Clashing Feelings volume after a decadeShiratori-san - Yesterday |
3 |
by Retro8bit
»»
5 hours ago |
|
» MyAnimeList x Honeyfeed Writing Contest 2025 SubmissionAvarion - Today |
1 |
by Retro8bit
»»
5 hours ago |
|
» MAL Analog HorrorWendy-- - Yesterday |
10 |
by Shizuna
»»
7 hours ago |
|
» Vladimir Volfovich Zhirinovsky's MAL Diary of Kawai MemoriesV_V_Zhirinovsky - Today |
1 |
by V_V_Zhirinovsky
»»
Today, 1:00 AM |
|
» New Android App – Shimeji Mascot Screen Petsshimejimascot - Sep 26 |
8 |
by hacker09
»»
Sep 26, 10:03 PM |