New
Dec 27, 2009 3:35 PM
#401
with talon's you might as well use the xml format and then change the content in the example... ie <content>[name:1] [current:1] / [total:1]</content> would be something like Bleach 150/? If you're using the traditional class structure (which I actually prefer), then it's not so easy changing it since it's buried in Signature.class.php.... however after poking around a bit I found you can manipulate the functions and make one: function writeCustomDescription($nr,$x,$y,$rule,$format="[status] - [current] / [total]",$rotation=0,$length=45,$align="l") ...that should be added wherever you like within the Signature class in lib/Signature.class.php -- then you can call it in your main sig file like this: $Signature->writeCustomDescription(1,100,50,$rule,"[current] / [total]"); you can use the other optional arguments and such also... it's the same as writeDescription() except with a format string after the $rule. It will substitute for [status], [current], and [total].... doesn't support units, but you didn't want them any way. If you did, you could add the extra str_replace() to the descriptionPart() function also in the Signature class. I didn't test it, but it should work... heh. |
Dec 27, 2009 6:31 PM
#402
I getting an error somewhere. I've checked but nothing seems to be wrong. Could someone help me troubleshoot? Thanks. I'm using saka's script. domain: pressit.webege.com image_output.php <?php ///////////////////////////////////////////////////////////////////// //generating the image $image = imagecreatefrompng("black-rock-shooterv1-1.png"); $font = 'moderna'; ///////dont change this////////////////// imagealphablending($image,true); imagesavealpha($image,true); //////////////////////////////////////// //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($image,255,255,255); //imagefttext(image, font size, angle, x-pos(relative to the image in px), y-pos, font color, fontfile, text output) ///////////anime-text output//////////////// imagefttext($image,11,49.5,75,138,$colour,$font,$titles[0][0]); imagefttext(11,11,50.5,99,137,$colour,$font,$status[0][0]); imagefttext($image,14,0,222,72,$colour,$font,$dates[0][0]); //////////////////////////////////////// ///////////manga-text output//////////////// imagefttext(11,49.5,75,138,$colour,$font,$titles[1][0]); imagefttext($image,11,50.5,99,137,$colour,$font,$status[1][0]); imagefttext($image,14,0,222,72,$colour,$font,$dates[1][0]); //////////////////////////////////////// imagepng($image, „sig.png“) imagedestroy($image); //we want our final image to be in the png format //imagepng ($image, "sig.png") //imagepng (image, save as); uncomment this line if you want to save your output and use a cronjob for automated update - otherwise leave it as it is //imagedestroy ($image); // ///////////////////////////////////////////////////////////////////// ?> settings.php <?php ///////////////////////////////////////////////////////////////////// //Settings to be used by the script //////////////// $user = "pressit"; //Mal-Username $to_parse = "1"; //what should be parsed?: 0=recent anime | 1=recent anime by episode | 2=recent manga | 3=recent manga by chapter | 4=recent anime AND recent manga | 5=recent anime by episode AND recent manga by episode $show_anime_type = "0"; // 1=yes or 0=no (if set to no it will cut out (TV|Movie|ONA|OVA|OAD|Special|Manga) ) ///////////////////////////////////////////////////////////////////// ///////////////Bonus settings; script will work even if you do not alter this settings $cut_titles = "1"; // 1=yes or 0=no $cut_title_after = "17"; // if you specified $cut_titles = "yes" enter the max char length of the anime title output $show_date = "0"; // 1=yes or 0=no; want to see the date of your last update? $time_format = "%d/%m/%y"; //time format you prefer; more Information here: http://www.php.net/manual/en/function.strftime.php ///////////////////////////////////////////////////////////////////// ////////////////Anime episodes-text; these are bonus settings and can be left aside if your ok with the default output $custom_episode_look = "1"; // 1=yes or 0=no (has to be 1 if you want to alter settings for mangas) $cut_spaces = "1"; // 1=yes (will look like: 12/24) or 0=no (will look like: 12 / 24); [also affects manga settings] $pre_watch = "@watching"; //define how the text starts e.g. if you want it to look like: @watching 2/24 you will have to set $pre = "@watching"; $rewatching= "@rewatching"; $middle_watch = "-"; //same as for $pre: example @watching 2/24 put $middle = "/"; [$middle effects the part between eps watched and total episodes number ////////Manga-Settings (only needed if you you parse manga updates and want a custom chapter/eps output) $after_watch = "#"; //what you'd like to appear after the total episodes number? e.g. 2/24# put $after = "#"; $pre_read = "@reading"; $middle_read = "/"; $after_read = "#"; //////////////// //end of settings-sector ///////////////////////////////////////////////////////////////////// ?> sig.php // specify the rss feed you want to use (see the bottom left of your MAL profile page) $user = "pressit"; // YOUR USERNAME $url_anime = "http://myanimelist.net/rss.php?type=rw&u=".$user; $url_manga = "http://myanimelist.net/rss.php?type=rm&u=".$user; // let's configure the cache $cachedpath = "cache/sig.png"; // a temporary copy of your signature will be stored here at the end check_cache(10); // time to cache signature in minutes, comment out this line for testing but put it back afterward! // IMPORTANT: YOUR 'cache' DIRECTORY MUST EXIST AND BE WRITABLE ON THE SERVER!!! (chmod 777 or change file properties using FTP) // * By default, the image only updates at most every ten minutes, but for testing/building your sig you may want to disable the cache by // commenting out the check_cache(...) line above (just add two slashes at the beginning of the line). Once your sig is working how // you'd like, put the cache check back in. I do not recommend leaving the cache disabled or setting it for less than 5 minutes, since // too low a setting can bombard MAL with lots of RSS requests and may also piss off your host. // * You can set your forum signature to use // you can alternatively link to ![]() // try to correct environment path @chdir(realpath(dirname($argv[0]))); /////////////////////////////////////////////////////////////////////////////////////////// // PARSING THE RSS FEED AND EXTRACTING DATA $anibuffer = file_get_contents($url_anime); $mangabuffer = file_get_contents($url_manga); if ( !($anibuffer) or !($mangabuffer) ) die("Could not download RSS feed"); // lets fix the status in the manga feeds so they make sense, and so we can differentiate from anime (silly Xinil) $mangabuffer = strtr($mangabuffer, array('>Plan to Watch'=>'>Plan to Read','>Watching'=>'>Reading','>Rewatching'=>'>Re-Reading','>On-Hold'=>'>Reading On Hold','>Completed'=>'>Finished Reading') ); // easiest to parse if we just merge the feeds together and parse all at once $buffer = $anibuffer . $mangabuffer; // now we have to sanitize the information we saved to the buffer (no newlines/tabs and replace xml entities) $buffer = strtr($buffer, array("\n" => '', "\r" => '', "\t" => '', '<' => '<', '>'=>'>', '&' => '&', '"' => '"', '''=>"'") ); // these lines just extract the anime title and status information into $titles[] and $status[] arrays, plus other info preg_match_all("/<item><title>([^<]*)<\/title>/i", $buffer, $titlematches); preg_match_all("/<description>([^<]*) - ([\d?]+) of ([\d?]+) (episodes?|chapters?)<\/description>/i", $buffer, $statusmatches); preg_match_all("/<pubDate>([^<]*)<\/pubDate>/i", $buffer, $timematches); $titles = $titlematches[1]; // $anititles is now an array of titles $status = $statusmatches[1]; // $anistatus is now an array of statuses $current = $statusmatches[2]; // $current is now an array of all the current episodes/chapters $totals = $statusmatches[3]; // $totals is now an array of all the episode/chapter totals $units = $statusmatches[4]; // $units is now an array of 'episode(s)' or 'chapter(s)' $timestamps = $timematches[1]; // $timestamps is now an array of dates watched/read // let's go through the whole list and format it how we want for($i = 0; $i < count($titles); $i++) { // convert timestamps to unix timestamps (numbers) so we can sort them properly later (don't change this line) $timestamps[$i] = strtotime($timestamps[$i]); // FORMAT THE TITLE VALUES // just remove all that junk at the end $titles[$i] = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special|Manga|Manhwa|Manhua|Novel|One Shot|Doujin|OEL)$/', '', $titles[$i]); // limit the titles to 21 characters; adjust this to your needs $titles[$i] = textlimit($titles[$i],17); // FORMAT THE STATUS VALUES - you can change the format as you like if ($status[$i] == "Watching" or $status[$i] == "Rewatching" or $status[$i] == "Reading" or $status[$i] == "Re-Reading") { $status[$i] = "$status[$i] at $current[$i] of $totals[$i] $units[$i]"; } else { // "Completed, "Plan to Watch", "Dropped", or "On Hold" $status[$i] = "$status[$i]"; // doesn't really do anything, but feel free to modify } $status[$i] = strtolower($status[$i]); // make all the statuses lowercase } // sort all of the arrays by the timestamps, so that the most recent entries are first array_multisort($timestamps,SORT_DESC,$titles,$status,$current,$totals,$units); /////////////////////////////////////////////////////////////////////////////////////////// // LET'S START GENERATING THE SIGNATURE IMAGE $sigimage = open_image("black-rock-shooterv1-1.png"); // load your background image // WRITE THE TEXT ONTO THE IMAGE $font = 'moderna.ttf'; // if you use another font, make sure you copy the *.ttf file into the same directory // let's define a font color - the last three arguments are the red, green, and blue values (so 0,0,0 = black and 255,255,255 = white) $colour = imagecolorallocate($sigimage,255,255,255); $colour2 = imagecolorallocate($sigimage,255,255,255); // draw the text - the template is imagettftext(image, font size, angle, x-pos, y-pos, font color, fontfile, text output, 'c' or 'l' or 'r') imagettftextalign($sigimage,11,49.5,75,138,$colour,$font,$titles[0],'r'); imagettftextalign($sigimage,11,50.5,99,137,$colour2,$font,$status[0],'r'); imagettftextalign($sigimage,11,49.5,75,138,$colour,$font,$titles[1],'r'); imagettftextalign($sigimage,11,50.5,99,137,$colour2,$font,$status[1],'r'); // OVERLAY ANOTHER IMAGE over the font and background (optional) //overlay_image("overlay.png"); // finally, let's output our pretty signature image to the browser header("Content-type: image/png"); imagepng($sigimage); @imagepng($sigimage, $cachedpath); // try to save a copy of our signature to the cache location we set earlier /////////////////////////////////////////////////////////////////////////////////////////// // Don't modify below here... just a few helping functions that can be called in the above code // textlimit($string, $length) takes any $string you pass it and resturns it shortened to $length characters (use it to limit title length) function textlimit($string, $length=25) { return (strlen(trim($string))>$length ? trim( substr(trim($string),0,$length-3) )."..." : $string); } // textlimitpx($string, $pixels, $font) returns the shortened $string that fits within exactly $pixels width horizontally when using $font and $size function textlimitpx($string, $pixels, $font, $size) { for($k = strlen(trim($string)); $k > 0; $k--) { $box = imagettfbbox($size,0,$font,textlimit($string,$k)); $w = $box[2] - $box[0]; if ($w <= $pixels) break; } return textlimit($string,$k); } // overlay_image($baseimage,$overlaypath,$x,$y) opens the image at $imagepath and overlays it onto $sigimage at position ($x, $y) // most image types should work, but 24-bit/true color PNG is recommended if you need transparency function overlay_image($overlaypath,$x=0,$y=0) { global $sigimage; $overlay = open_image($overlaypath); // open any image imagecopy($sigimage, $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay)); // overlay onto our base image @imagedestroy($overlay); // clean up memory, since we don't need the overlay image anymore } // open_image($path) will load an image into memory so we can work with it, and return an error if we fail function open_image($path) { $image = @imagecreatefromstring(file_get_contents($path)); if (!$image) die("could not open image ($path) make sure it exists"); imagealphablending($image,true); imagesavealpha($image,true); // preserve transparency return $image; } // check_cache($minutes) returns a cached image and stops execution if $minutes has not passed since the last update function check_cache($minutes) { global $cachedpath; if ( !( is_writable($cachedpath) or is_writable(dirname($cachedpath)) and !file_exists($cachedpath) ) ) die("The cache is not writable; please change it to 777 permissions using FTP.\n\$cachedpath = {$cachedpath}"); if ( time() - @filemtime($cachedpath) < 60*$minutes ) { header("Content-type: image/png"); echo file_get_contents($cachedpath); exit(0); } } // imagettftextalign() is basically a wrapper for imagettftext() to add the ability to center/right-align text to a point // the $align argument can be 'c' for center, 'r' for right align, or 'l' for left align (default) function imagettftextalign(&$img,$size,$angle,$x,$y,&$c,$font,$string,$align='l') { $box = imagettfbbox($size,$angle,$font,$string); $w = $box[2] - $box[0]; $h = $box[3] - $box[1]; switch (strtolower($align)) { case 'r': $x -= $w; $y -= $h; break; case 'c': $x -= $w/2; $y -= $h/2; break; } imagettftext($img,$size,$angle,$x,$y,$c,$font,$string); } ?> Many thanks to whoever bothered to read this. Its tedious checking i know :[ |
PRESSitDec 27, 2009 6:58 PM
Dec 27, 2009 7:02 PM
#403
looks like only the last few bits of my script got pasted.... I guessed the directory and found the files in http://pressit.webege.com/signature/ but since you're under admin review there's not much I can do. I guess I'll just adapt your old settings to a fresh copy of my script after dinner. ;) |
Dec 27, 2009 7:09 PM
#404
Thanks ^^. yep i noticed that and updated my post, but i guess u saw the old post. |
Dec 27, 2009 7:47 PM
#405
for some reason the one you posted has ";.$user; on the anime and manga urls... not sure if that's in your script or the mal forums are adding stuff (as they sometimes do), but when i change that to the correct lines it works: $url_anime = "http://myanimelist.net/rss.php?type=rw&u=".$user; $url_manga = "http://myanimelist.net/rss.php?type=rm&u=".$user; ![]() ^ the text is way down at the bottom of the image, but it is working correctly. edit..... and indeed mal adds semicolons for some reason.... ~.~ ..... should look like this at the top, but otherwise the code is correct: ![]() btw, mal's usernames are not case sensitive.... just did it for caution ;) |
sakaDec 27, 2009 7:50 PM
Dec 27, 2009 8:25 PM
#406
I'm not sure whats wrong, but sig.png isn't generated. Also, if I were to change my angles to -49.5, with the '-' symbol, would it affect the script? Sorry for the trouble >< |
Dec 27, 2009 10:21 PM
#407
make sure there's an empty directory called 'cache' and that you make it writable after you upload it (777 permissions). the dialog when you right click on the cache folder and choose File Permissions should look like this: ![]() and yes, negative works fine for angle.... though I did notice you tend to use decimal numbers for the x,y coordinates a lot... those get rounded to the whole number anyway so you shouldn't bother. I think the angles are floats though. |
Dec 28, 2009 6:11 AM
#408
Thats the problem i have. The cache folder permissions have been enabled, yet sig.png isn't generated. I wasn't sure if it was a problem with the file locations, so i moved them around a bit too. Same result. I was wondering if it might be a problem with the parent directory(file_html) file permissions? Edit: Updated script for troubleshooting domain:pressit.webege.com sig.php // specify the rss feed you want to use (see the bottom left of your MAL profile page) $user = "PresSiT"; // YOUR USERNAME $url_anime = "http://myanimelist.net/rss.php?type=rw&u=".$user; $url_manga = "http://myanimelist.net/rss.php?type=rm&u=".$user; // let's configure the cache $cachedpath = "signature/cache/sig.png"; // a temporary copy of your signature will be stored here at the end check_cache(10); // time to cache signature in minutes, comment out this line for testing but put it back afterward! // IMPORTANT: YOUR 'cache' DIRECTORY MUST EXIST AND BE WRITABLE ON THE SERVER!!! (chmod 777 or change file properties using FTP) // * By default, the image only updates at most every ten minutes, but for testing/building your sig you may want to disable the cache by // commenting out the check_cache(...) line above (just add two slashes at the beginning of the line). Once your sig is working how // you'd like, put the cache check back in. I do not recommend leaving the cache disabled or setting it for less than 5 minutes, since // too low a setting can bombard MAL with lots of RSS requests and may also piss off your host. // * You can set your forum signature to use // you can alternatively link to ![]() have a cronjob visit the php url every few minutes // try to correct environment path @chdir(realpath(dirname($argv[0]))); /////////////////////////////////////////////////////////////////////////////////////////// // PARSING THE RSS FEED AND EXTRACTING DATA $anibuffer = file_get_contents($url_anime); $mangabuffer = file_get_contents($url_manga); if ( !($anibuffer) or !($mangabuffer) ) die("Could not download RSS feed"); // lets fix the status in the manga feeds so they make sense, and so we can differentiate from anime (silly Xinil) $mangabuffer = strtr($mangabuffer, array('>Plan to Watch'=>'>Plan to Read','>Watching'=>'>Reading','>Rewatching'=>'>Re-Reading','>On-Hold'=>'>Reading On Hold','>Completed'=>'>Finished Reading') ); // easiest to parse if we just merge the feeds together and parse all at once $buffer = $anibuffer . $mangabuffer; // now we have to sanitize the information we saved to the buffer (no newlines/tabs and replace xml entities) $buffer = strtr($buffer, array("n" => '', "r" => '', "t" => '', '<' => '<', '>'=>'>', '&' => '&', '"' => '"', '''=>"'") ); // these lines just extract the anime title and status information into $titles[] and $status[] arrays, plus other info preg_match_all("/<item><title>([^<]*)</title>/i", $buffer, $titlematches); preg_match_all("/<description>([^<]*) - ([d?]+) of ([d?]+) (episodes?|chapters?) </description>/i", $buffer, $statusmatches); preg_match_all("/<pubDate>([^<]*)</pubDate>/i", $buffer, $timematches); $titles = $titlematches[1]; // $anititles is now an array of titles $status = $statusmatches[1]; // $anistatus is now an array of statuses $current = $statusmatches[2]; // $current is now an array of all the current episodes/chapters $totals = $statusmatches[3]; // $totals is now an array of all the episode/chapter totals $units = $statusmatches[4]; // $units is now an array of 'episode(s)' or 'chapter(s)' $timestamps = $timematches[1]; // $timestamps is now an array of dates watched/read // let's go through the whole list and format it how we want for($i = 0; $i < count($titles); $i++) { // convert timestamps to unix timestamps (numbers) so we can sort them properly later (don't change this line) $timestamps[$i] = strtotime($timestamps[$i]); // FORMAT THE TITLE VALUES // just remove all that junk at the end $titles[$i] = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special|Manga|Manhwa|Manhua|Novel|One Shot|Doujin|OEL)$/', '', $titles [$i]); // limit the titles to 21 characters; adjust this to your needs $titles[$i] = textlimit($titles[$i],17); // FORMAT THE STATUS VALUES - you can change the format as you like if ($status[$i] == "Watching" or $status[$i] == "Rewatching" or $status[$i] == "Reading" or $status[$i] == "Re-Reading") { $status[$i] = "$status[$i] at $current[$i] of $totals[$i] $units[$i]"; } else { // "Completed, "Plan to Watch", "Dropped", or "On Hold" $status[$i] = "$status[$i]"; // doesn't really do anything, but feel free to modify } $status[$i] = strtolower($status[$i]); // make all the statuses lowercase } // sort all of the arrays by the timestamps, so that the most recent entries are first array_multisort($timestamps,SORT_DESC,$titles,$status,$current,$totals,$units); /////////////////////////////////////////////////////////////////////////////////////////// // LET'S START GENERATING THE SIGNATURE IMAGE $sigimage = open_image("black-rock-shooterv1-1.png"); // load your background image // WRITE THE TEXT ONTO THE IMAGE $font = 'moderna.ttf'; // if you use another font, make sure you copy the *.ttf file into the same directory // let's define a font color - the last three arguments are the red, green, and blue values (so 0,0,0 = black and 255,255,255 = white) $colour = imagecolorallocate($sigimage,255,255,255); $colour2 = imagecolorallocate($sigimage,255,255,255); // draw the text - the template is imagettftext(image, font size, angle, x-pos, y-pos, font color, fontfile, text output, 'c' or 'l' or 'r') imagettftextalign($sigimage,11,-49,75,138,$colour,$font,$titles[0],'r'); imagettftextalign($sigimage,11,-50,99,137,$colour2,$font,$status[0],'r'); imagettftextalign($sigimage,11,-49,75,138,$colour,$font,$titles[1],'r'); imagettftextalign($sigimage,11,-50,99,137,$colour2,$font,$status[1],'r'); // OVERLAY ANOTHER IMAGE over the font and background (optional) //overlay_image("overlay.png"); // finally, let's output our pretty signature image to the browser header("Content-type: image/png"); imagepng($sigimage); @imagepng($sigimage, $cachedpath); // try to save a copy of our signature to the cache location we set earlier /////////////////////////////////////////////////////////////////////////////////////////// // Don't modify below here... just a few helping functions that can be called in the above code // textlimit($string, $length) takes any $string you pass it and resturns it shortened to $length characters (use it to limit title length) function textlimit($string, $length=25) { return (strlen(trim($string))>$length ? trim( substr(trim($string),0,$length-3) )."..." : $string); } // textlimitpx($string, $pixels, $font) returns the shortened $string that fits within exactly $pixels width horizontally when using $font and $size function textlimitpx($string, $pixels, $font, $size) { for($k = strlen(trim($string)); $k > 0; $k--) { $box = imagettfbbox($size,0,$font,textlimit($string,$k)); $w = $box[2] - $box[0]; if ($w <= $pixels) break; } return textlimit($string,$k); } // overlay_image($baseimage,$overlaypath,$x,$y) opens the image at $imagepath and overlays it onto $sigimage at position ($x, $y) // most image types should work, but 24-bit/true color PNG is recommended if you need transparency function overlay_image($overlaypath,$x=0,$y=0) { global $sigimage; $overlay = open_image($overlaypath); // open any image imagecopy($sigimage, $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay)); // overlay onto our base image @imagedestroy($overlay); // clean up memory, since we don't need the overlay image anymore } // open_image($path) will load an image into memory so we can work with it, and return an error if we fail function open_image($path) { $image = @imagecreatefromstring(file_get_contents($path)); if (!$image) die("could not open image ($path) make sure it exists"); imagealphablending($image,true); imagesavealpha($image,true); // preserve transparency return $image; } // check_cache($minutes) returns a cached image and stops execution if $minutes has not passed since the last update function check_cache($minutes) { global $cachedpath; if ( !( is_writable($cachedpath) or is_writable(dirname($cachedpath)) and !file_exists ($cachedpath) ) ) die("The cache is not writable; please change it to 777 permissions using FTP.n$cachedpath = {$cachedpath}"); if ( time() - @filemtime($cachedpath) < 60*$minutes ) { header("Content-type: image/png"); echo file_get_contents($cachedpath); exit(0); } } // imagettftextalign() is basically a wrapper for imagettftext() to add the ability to center/right-align text to a point // the $align argument can be 'c' for center, 'r' for right align, or 'l' for left align (default) function imagettftextalign(&$img,$size,$angle,$x,$y,&$c,$font,$string,$align='l') { $box = imagettfbbox($size,$angle,$font,$string); $w = $box[2] - $box[0]; $h = $box[3] - $box[1]; switch (strtolower($align)) { case 'r': $x -= $w; $y -= $h; break; case 'c': $x -= $w/2; $y -= $h/2; break; } imagettftext($img,$size,$angle,$x,$y,$c,$font,$string); } ?> settings.php <?php ///////////////////////////////////////////////////////////////////// //Settings to be used by the script //////////////// $user = "pressit"; //Mal-Username $to_parse = "1"; //what should be parsed?: 0=recent anime | 1=recent anime by episode | 2=recent manga | 3=recent manga by chapter | 4=recent anime AND recent manga | 5=recent anime by episode AND recent manga by episode $show_anime_type = "0"; // 1=yes or 0=no (if set to no it will cut out (TV|Movie|ONA|OVA|OAD|Special|Manga) ) ///////////////////////////////////////////////////////////////////// ///////////////Bonus settings; script will work even if you do not alter this settings $cut_titles = "1"; // 1=yes or 0=no $cut_title_after = "17"; // if you specified $cut_titles = "yes" enter the max char length of the anime title output $show_date = "0"; // 1=yes or 0=no; want to see the date of your last update? $time_format = "%d/%m/%y"; //time format you prefer; more Information here: http://www.php.net/manual/en/function.strftime.php ///////////////////////////////////////////////////////////////////// ////////////////Anime episodes-text; these are bonus settings and can be left aside if your ok with the default output $custom_episode_look = "1"; // 1=yes or 0=no (has to be 1 if you want to alter settings for mangas) $cut_spaces = "0"; // 1=yes (will look like: 12/24) or 0=no (will look like: 12 / 24); [also affects manga settings] $pre_watch = "@watching"; //define how the text starts e.g. if you want it to look like: @watching 2/24 you will have to set $pre = "@watching"; $rewatching= "@rewatching"; $middle_watch = "of"; //same as for $pre: example @watching 2/24 put $middle = "/"; [$middle effects the part between eps watched and total episodes number ////////Manga-Settings (only needed if you you parse manga updates and want a custom chapter/eps output) $after_watch = "#"; //what you'd like to appear after the total episodes number? e.g. 2/24# put $after = "#"; $pre_read = "@reading"; $middle_read = "/"; $after_read = "#"; //////////////// //end of settings-sector ///////////////////////////////////////////////////////////////////// ?> image_output.php <?php ///////////////////////////////////////////////////////////////////// //generating the image $image = imagecreatefrompng("black-rock-shooterv1-1.png"); $font = 'moderna'; ///////dont change this////////////////// imagealphablending($image,true); imagesavealpha($image,true); //////////////////////////////////////// //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($image,255,255,255); //imagefttext(image, font size, angle, x-pos(relative to the image in px), y-pos, font color, fontfile, text output) ///////////anime-text output//////////////// imagefttext($image,11,49,75,138,$colour,$font,$titles[0][0]); imagefttext(11,11,50,99,137,$colour,$font,$status[0][0]); imagefttext($image,14,0,222,72,$colour,$font,$dates[0][0]); //////////////////////////////////////// ///////////manga-text output//////////////// imagefttext(11,49.5,75,138,$colour,$font,$titles[1][0]); imagefttext($image,11,50.5,99,137,$colour,$font,$status[1][0]); imagefttext($image,14,0,222,72,$colour,$font,$dates[1][0]); //////////////////////////////////////// imagepng($image, "sig.png")//we want our final image to be in the png format //imagepng ($image, "sig.png") //imagepng (image, save as); uncomment this line if you want to save your output and use a cronjob for automated update - otherwise leave it as it is //imagedestroy ($image); // ///////////////////////////////////////////////////////////////////// ?> |
PRESSitDec 28, 2009 7:03 AM
Dec 28, 2009 8:53 AM
#409
you're missing the top part of the script (the opening <?php and the license) and because of that it isn't recognizing your file as php. add this to the very beginning of your file: <?php /******************************************************************** * saka's minimal signature script - v1.21 (anime/manga merged) * http://myanimelist.net/forum/?topicid=84446 * This code may be reused under the terms of the Creative Commons License (Attribution+NonCommercial+ShareAlike) * http://creativecommons.org/licenses/by-nc-sa/3.0/ *********************************************************************/ btw, there's no need for settings.php and image_output.php anymore, since it's all in sig.php ;) |
Dec 28, 2009 10:05 AM
#410
That solved the problem. Its done! Thanks saka ^^ |
Jan 29, 2010 10:21 PM
#411
Feb 6, 2010 6:26 AM
#412
my head hurts im not geting any of this |
Feb 6, 2010 6:45 AM
#413
I would suggest you saka's minimal script, its quite easier than ehrgeiz's and quite a lot people use it, me included. :) http://myanimelist.net/forum/?topicid=84446 |
Mar 5, 2010 10:52 AM
#414
Thanks, ehrgeiz! That helped me make my 1st php sig (I used saka's script though). I have some questions for upcoming signatures: -It was a real pain adjusting the text position, is there an easier way to figure its exact coordinates without trying multiple times, sometimes with a 5-8 min waiting interval in-between for the changes to appear? I tried Paint, but it only helped me with x-pos. -How can I use more than one font? Say, one for the series name and one for the status? -In general, is it possible to warp text, apply different blending options and character palette options? Sorry, if any of those were asked before… |
Sesame-chanMar 5, 2010 11:08 AM
Mar 22, 2010 7:26 PM
#415
I'm having trouble getting the image to display. Every time I try to navigate to the site, it doesnt work. I configured the Chmod the way it was supposed to be for each of the files, including my own sig picture, and I just left the font alone b/c this is just a test sig Also, will my sig update at all without a cronjob? any help would be awesome |
Mar 23, 2010 1:38 PM
#416
Yes it will update without a cronjob and return the image directly from the php. You can use a cronjob to make it slightly more efficient, but it's completely optional and really unnecessary unless you have a very very complicated sig that takes a while to generate. btw, in response to your pm, I'm making a couple minor fixes and writing up a tutorial for configuring my minimal script that I'll post soon. It should be easier with detailed instructions. ;) |
Mar 24, 2010 3:05 PM
#417
That wasn't nice! :/ |
Mar 24, 2010 4:18 PM
#418
lol sorry i somehow overlooked you.... didn't mean to ignore. ;) Sesame-chan said: -It was a real pain adjusting the text position, is there an easier way to figure its exact coordinates without trying multiple times, sometimes with a 5-8 min waiting interval in-between for the changes to appear? For positioning, I find it helpful to mock up everything in photoshop first (including the text) so that I can use photoshop to measure the coordinates beforehand. If you want to do this, go to Edit>Preferences>Units & Rulers to make sure your measurements for Rulers and Type are in pixels; Now use the F8 key on your keyboard to toggle the Info Panel, which gives you pixel measurements of the width, height, and position of the element you're working with. It's odd that your script isn't updating after you change it... the check_cache() function should check to see if your script has been modified and cause it to make a new one, but if it's being stubborn you can comment out the check_cache(...); line near the top. Just put '//' in front like this: //check_cache(10); and take the /'s back out when you've gotten it to your liking. Sesame-chan said: -How can I use more than one font? Say, one for the series name and one for the status? All of the text functions take just the path to the font... so it's just a string and you can use as many as you want. $font = 'font.ttf'; and change to $font2 or whichever in the imagettftextalign() functions below that.$font2 = 'font2.ttf'; $font3 = 'font3.ttf'; ... Sesame-chan said: -In general, is it possible to warp text, apply different blending options and character palette options? I'm not sure what you mean by character palette, but you can use additional libraries (extra php files with functions in them) to add effects to your text and other dynamic content. I've already written functions to do 3d perspective rotation, skew, 2d rotation(with alpha support), and am working on perfecting a library that does all the photoshop blending modes (just a few minor quirks to work out with the alpha blending). Many people also use Niroko's glow library to add glow effects to my sig script. If you have specific questions, just ask... preferably in the thread for my minimal sig though. |
Mar 24, 2010 5:33 PM
#419
Wow! That was well explained, thank you so much! I'll post my comment in your thread then :) |
Mar 26, 2010 9:35 PM
#420
saka said: Yes it will update without a cronjob and return the image directly from the php. You can use a cronjob to make it slightly more efficient, but it's completely optional and really unnecessary unless you have a very very complicated sig that takes a while to generate. btw, in response to your pm, I'm making a couple minor fixes and writing up a tutorial for configuring my minimal script that I'll post soon. It should be easier with detailed instructions. ;) wow, awesome, thanks a lot! I'll be looking forward to it =) |
May 2, 2010 10:33 PM
#421
Jul 18, 2010 2:34 PM
#422
can i make from this just a text output? i tried with $cutter vars to include in my script but it does't work properly. it displays rss last news (must show first) |
I'm a Mog, half man half dog. I'm my own best friend (c) Spaceballs |
Jul 18, 2010 7:15 PM
#423
I highly recommend not using this script. There are better ones available that are more modular. mine: http://myanimelist.net/forum/?topicid=84446 talon/niroko's: http://myanimelist.net/forum/?topicid=32704 scripter's club with more: http://myanimelist.net/clubs.php?cid=5076 If you're just looking for ways to parse rss, there are simple general ways to do it. Ask me privately what you need and maybe I can help. |
Jul 16, 2012 6:13 AM
#425
helpoemer07 said: okay... I'm in a pinch... I'm done with almost everything... I have an image, I have edited the codes for image_output.php and settings.php (not sig.php), I have set the chmod for the folder containing them to 777, and I have set the chmod for all the files to 755... Whenever I use http://helpoemer07.0fees.net/signature/sig.php inside a bbcode or even at the address bar, an image error occurs (a small broken image picture)... when I try to use http://helpoemer07.0fees.net/signature/image_output.php , my original image displays but without the list that I wanted to display... What could I have done wrong?? (I have not edited the sig.php in any way aside the chmod)... Is it because of my host (0fees) ?? I'm in dire need of your help... thanks... ^_^ ~ and oh... just in case... I'll place the codes... image_output.php <?php ///////////////////////////////////////////////////////////////////// //generating the image $image = imagecreatefrompng("signature_copy.png"); $font = 'my_font'; ///////dont change this////////////////// imagealphablending($image,true); imagesavealpha($image,true); //////////////////////////////////////// //imagecolorexact(image,0,0,0) //imagecolorexact($blub,0,0,0) = black font | imagecolorexact($blub,255,255,255) = white font $colour = imagecolorexact($image,0,0,255); //imagefttext(image, font size, angle, x-pos(relative to the image in px), y-pos, font color, fontfile, text output) ///////////anime-text output//////////////// imagefttext($image,14,0,118,48,$colour,$font,$titles[0][0]); imagefttext($image,12,0,170,60,$colour,$font,$status[0][0]); //////////////////////////////////////// imagepng ($image); //we want our final image to be in the png format //imagepng ($image, "sig.png") //imagepng (image, save as); uncomment this line if you want to save your output and use a cronjob for automated update - otherwise leave it as it is //imagedestroy ($image); // ///////////////////////////////////////////////////////////////////// ?> settings.php <?php ///////////////////////////////////////////////////////////////////// //Settings to be used by the script //////////////// $user = "helpoemer07"; //Mal-Username $to_parse = "5"; //what should be parsed?: 0=recent anime | 1=recent anime by episode | 2=recent manga | 3=recent manga by chapter | 4=recent anime AND recent manga | 5=recent anime by episode AND recent manga by episode $show_anime_type = "1"; // 1=yes or 0=no (if set to no it will cut out (TV|Movie|ONA|OVA|OAD|Special|Manga) ) ///////////////////////////////////////////////////////////////////// ///////////////Bonus settings; script will work even if you do not alter this settings $cut_titles = "0"; // 1=yes or 0=no $cut_title_after = "25"; // if you specified $cut_titles = "yes" enter the max char length of the anime title output $show_date = "0"; // 1=yes or 0=no; want to see the date of your last update? $time_format = "%d/%m/%y"; //time format you prefer; more Information here: http://www.php.net/manual/en/function.strftime.php ///////////////////////////////////////////////////////////////////// ////////////////Anime episodes-text; these are bonus settings and can be left aside if your ok with the default output $custom_episode_look = "1"; // 1=yes or 0=no (has to be 1 if you want to alter settings for mangas) $cut_spaces = "1"; // 1=yes (will look like: 12/24) or 0=no (will look like: 12 / 24); [also affects manga settings] $pre_watch = "@watching"; //define how the text starts e.g. if you want it to look like: @watching 2/24 you will have to set $pre = "@watching"; $rewatching= "@rewatching"; $middle_watch = "-"; //same as for $pre: example @watching 2/24 put $middle = "/"; [$middle effects the part between eps watched and total episodes number ////////Manga-Settings (only needed if you you parse manga updates and want a custom chapter/eps output) $after_watch = "#"; //what you'd like to appear after the total episodes number? e.g. 2/24# put $after = "#"; $pre_read = "@reading"; $middle_read = "/"; $after_read = "#"; //////////////// //end of settings-sector ///////////////////////////////////////////////////////////////////// ?> sig.php <?php header("Content-Type: image/png"); ///////////////////////////////////////////////////////////////////// //Settings to be used by the script //////////////// require("settings.php"); //////////////// //end of settings-sector; all modifications below and above this line are on your own responsibility ///////////////////////////////////////////////////////////////////// function createText($image,$size,$angle,$x,$y,$color,$font,$text,$border=false,$bordercolor=null,$bordersize=2){ if($border==true){ imagettftext($image, $size, $angle, $x-$bordersize, $y-$bordersize, $bordercolor, $font, $text); imagettftext($image, $size, $angle, $x, $y-$bordersize, $bordercolor, $font, $text); imagettftext($image, $size, $angle, $x+$bordersize, $y-$bordersize, $bordercolor, $font, $text); imagettftext($image, $size, $angle, $x-$bordersize, $y+$bordersize, $bordercolor, $font, $text); imagettftext($image, $size, $angle, $x, $y+$bordersize, $bordercolor, $font, $text); imagettftext($image, $size, $angle, $x+$bordersize, $y+$bordersize, $bordercolor, $font, $text); imagettftext($image, $size, $angle, $x-$bordersize, $y, $bordercolor, $font, $text); imagettftext($image, $size, $angle, $x+$bordersize, $y, $bordercolor, $font, $text); } imagettftext($image,$size,$angle,$x,$y, $color, $font, $text); } //specify the url that shall be read switch($to_parse){ case 0: $url = "http://myanimelist.net/rss.php?type=rw&u=$user"; $type_m = 0; break; case 1: $url = "http://myanimelist.net/rss.php?type=rwe&u=$user"; $type_m = 0; break; case 2: $url= "http://myanimelist.net/rss.php?type=rm&u=$user"; $p_manga = 1; $type_m = 1; break; case 3: $url = "http://myanimelist.net/rss.php?type=rrm&u=$user"; $p_manga = 1; $type_m = 1; break; case 4: $url = "http://myanimelist.net/rss.php?type=rw&u=$user"; $url_x = "http://myanimelist.net/rss.php?type=rm&u=$user"; $file2 = @fopen ("$url_x","r"); $p_manga = 1;$type_m = 0; break; case 5: $url = "http://myanimelist.net/rss.php?type=rwe&u=$user"; $url_x = "http://myanimelist.net/rss.php?type=rrm&u=$user"; $file2 = @fopen ("$url_x","r"); $p_manga = 1;$type_m = 0; break; } //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>"; $date = "<pubDate>"; $dateend = "</pubDate>"; $reading = "<description>Reading -"; /////////////////////////// //rss-parser(Anime-Titles) if (trim($file) == "") { if($file2 != ""){echo"only mangas are being parsed";}else{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[0][$i] = fgets($file,1024); $i++;$files = "1"; } fclose($file);//close the file if($file2 != ""){$x=0; while (!feof($file2)) { //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[1][$x] = fgets($file2,1024); $x++;$files = "2"; } fclose($file2);//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 ($type=0;$type<$files;$type++){$t = 0; for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$type][$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 array $cutter = str_replace($end,"",$ncnt); $cta = $cut_title_after - 3; if ($cut_titles == "1" && strlen($cutter) > $cta){ $cutter = str_replace($end,"",$ncnt); $cutter = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special|Manga)$/', '', $cutter); $titles[$type][$t] = substr($cutter, 0, $cut_title_after); $titles[$type][$t] .= "..."; } else{ if($show_anime_type == "0"){ $remover = str_replace($end,"",$ncnt); $titles[$type][$t] = preg_replace('/ - (TV|Movie|ONA|OVA|OAD|Special|Manga)$/', '', $remover); } else{ $titles[$type][$t] = str_replace($end,"",$ncnt); } } $t++; } } } //this for-loop just extracts the date information for ($type=0;$type<$files;$type++){$d = 0; if($show_date == "1"){ for ($j=1;$j<$i;$j++) { if ($cnt = strstr($buffer[$type][$j],$date)) { $ncnt = str_replace($date, "", $cnt); $end = strstr($ncnt, $dateend); $tmpstring = str_replace($end,"",$ncnt); $dates[$type][$d] = strftime("$time_format",strtotime($tmpstring)); $d++; } } } } //this for-loop just extracts the anime_episode information for ($type=0;$type<$files;$type++){$z = 0; for ($j=1;$j<$i;$j++) { //episodes if ($cnt = strstr($buffer[$type][$j],$ptw)) { $status[$type][$z] = "plan to watch"; $z++; } if ($cnt = strstr($buffer[$type][$j],$completed)) { $re = str_replace($completed, "", $cnt); $re = str_replace(" of ", "-", $re); $re = str_replace(episodes, "", $re); $re2 = explode("-",$re); $re_int1 = (int)$re2[0]; $re_int2 = (int)$re2[1]; if($re_int1 == $re_int2){ $status[$type][$z] = "completed"; } else{ $ncnt = str_replace($completed, $rewatching, $cnt); if($cut_spaces == "1"){ $ncnt = str_replace(" of ", $middle_watch, $ncnt);} $ncnt = str_replace(of, $middle_watch, $ncnt); $ncnt = str_replace(episodes, $after_watch, $ncnt); $end2 = strstr($ncnt, $descend); $status[$type][$z] = str_replace($end2,"",$ncnt); } $z++; } if ($cnt = strstr($buffer[$type][$j],$onhold)) { $status[$type][$z] = "on hold"; $z++; } if ($cnt = strstr($buffer[$type][$j],$dropped)) { $status[$type][$z] = "dropped"; $z++; } if ($cnt = strstr($buffer[$type][$j],$watching)){ if($type == 0 && $type_m == 0){ if($custom_episode_look == "0"){ $ncnt = str_replace($watching, "", $cnt); $end2 = strstr($ncnt, $descend); $status[$type][$z] = str_replace($end2,"",$ncnt);$z++; }else{ $ncnt = str_replace($watching, $pre_watch, $cnt); if($cut_spaces == "1"){ $ncnt = str_replace(" of ", $middle_watch, $ncnt);} $ncnt = str_replace(of, $middle_watch, $ncnt); $ncnt = str_replace(episodes, $after_watch, $ncnt); $end2 = strstr($ncnt, $descend); $status[$type][$z] = str_replace($end2,"",$ncnt);$z++; } } else { if($cnt = strstr($buffer[$type][$j],$watching)){ if($custom_episode_look == "0"){ $ncnt = str_replace($watching, "", $cnt); $end2 = strstr($ncnt, $descend); $status[$type][$z] = str_replace($end2,"",$ncnt);$z++; }else{ $ncnt = str_replace($watching, $pre_read, $cnt); if($cut_spaces == "1"){ $ncnt = str_replace(" of ", $middle_read, $ncnt);} $ncnt = str_replace(of, $middle_watch, $ncnt); $ncnt = str_replace(episodes, $after_read, $ncnt); $end2 = strstr($ncnt, $descend); $status[$type][$z] = str_replace($end2,"",$ncnt);$z++; } //$z++; } } } if ($cnt = strstr($buffer[$type][$j],$reading)){ if($custom_episode_look == "0"){ $ncnt = str_replace($reading, "", $cnt); $end2 = strstr($ncnt, $descend); $status[$type][$z] = str_replace($end2,"",$ncnt);$z++; }else{ $ncnt = str_replace($reading, $pre_read, $cnt); if($cut_spaces == "1"){ $ncnt = str_replace(" of ", $middle_read, $ncnt);} $ncnt = str_replace(of, $middle_watch, $ncnt); $ncnt = str_replace(episodes, $after_read, $ncnt); $end2 = strstr($ncnt, $descend); $status[$type][$z] = str_replace($end2,"",$ncnt);$z++; } } }} ///////////////////////////////////////////////////////////////////// //generating the image require("image_output.php"); ?> Hello..ive been working on my sginature for 7 hours and i have reached the same place he is..i am useing Freewebhosting.com and i saw it does allow allow_url_fopen...anyone know what i am doing wrong..if you want i can post my Codes.. |
More topics from this board
» Four Ages!Robert_SS_Gordon - Feb 21 |
48 |
by Robert_SS_Gordon
»»
4 hours ago |
|
» New Android App – Shimeji Mascot Screen Petsshimejimascot - 5 hours ago |
2 |
by shimejimascot
»»
4 hours ago |
|
» 【 ART THREAD 】Let's share our art! ❤︎ ( 1 2 3 4 5 )mewmewforever - Aug 30, 2024 |
209 |
by Absurdo_N
»»
Yesterday, 5:48 PM |
|
» AniTaste - cross-site anime list comparatorMciej - Sep 21 |
1 |
by Retro8bit
»»
Sep 21, 5:29 PM |
|
» Saeryen's Songs!Saeryen - Jul 25 |
5 |
by Saeryen
»»
Sep 20, 1:54 PM |