Recommended Posts

I created an image signature in that grabs the title of the latest post in your rss feed.

NOTE: They work well, but aren't close to production quality so don't expect that yet

PHP & GD2 Version: rss.txt (rename as .php and open it in a text editor to configure it)

ASP.NET Version: RSSImageSig.zip (setup in iis, configure in web.config and run Default.aspx)

Original Topic

Edited by benjeeeboy
Link to comment
https://www.neowin.net/forum/topic/348463-rss-image-signature/
Share on other sites

I plan on eventually doing animated gifs.

The setback for this is that there doesn't seem to be a built in way in PHP/GD or ASP.NET to do this. It may be easier in PHP w/ ImageMagick, but i haven't looked into that. Even if it isn't built in, it should be possible to hack it together by generating multiple frames, and then putting those together into an animated gif.

Another alternative, is to generate SWF through Ming (I believe that there is something similar in asp.net).

mynimal, I'm not exactly sure why yours doesn't work. My configuration looks like this: (a.jpg is just my copy of your image)

$feedurl = "http://blog.mynimal.net/?feed=rss2";
$imageurl = "a.png";
$imageinputtype = 'png';
$imageoutputtype = 'png';
$problemwithfeedtext = 'Problem loading feed';
$problemwithimagetext = 'Problem loading image';
$font = 'arial.ttf';
$fontcolor = array(255,255,255); //array (r,g,b)
$fontsize = 12;
$fontantialiased = TRUE;
$x = 65;
$y = 16;
$angle = 0;
$maxwidth = NULL;
$maxheight = NULL;
$toofarstr = '...';

If this doesn't work for you, then could you tell me your version of PHP & GD?

Just done one for the Neowin forum RSS, will you repost the old script, as I find it easier to use, as there aren't so many options!

forum.php

Bare in mind I did this one in Paint :p

I've just seen an error on it now, if the feed contains an invalid character - like to "&" a minute ago, it showed up as &amp :p

Edited by TimRogers

Pretty cool but it goes of the edge, which i corrected in the new one.

Yah, the script configuration is pretty complicated so i'll try to group the options together and show which ones are more important.

I like the idea of the designer -- i will probably try to make one.

Yah, the & error is a problem in alot of applications that use rss feeds (open a feed in firefox with a & in it and it will show it like that too), but i can fix that relatively easily. The problem is that i think that there are alot of characters that show up like that and it may cause the script to slow down if i try to elimate all of them.

The other thing i was thinking about is whether there is a good way to make it easy to link the image to the post that it is showing the title for. I can think of a bunch of ways, but none of them are very good.

mynimal, I'm not exactly sure why yours doesn't work.  My configuration looks like this: (a.jpg is just my copy of your image)

$feedurl = "http://blog.mynimal.net/?feed=rss2";
$imageurl = "a.png";
$imageinputtype = 'png';
$imageoutputtype = 'png';
$problemwithfeedtext = 'Problem loading feed';
$problemwithimagetext = 'Problem loading image';
$font = 'arial.ttf';
$fontcolor = array(255,255,255); //array (r,g,b)
$fontsize = 12;
$fontantialiased = TRUE;
$x = 65;
$y = 16;
$angle = 0;
$maxwidth = NULL;
$maxheight = NULL;
$toofarstr = '...';

If this doesn't work for you, then could you tell me your version of PHP & GD?

586264454[/snapback]

I'm beginning to think it's my host that's the problem.

I mean, look at this:

http://www.mynimal.net/rss/info.php

PHP version is 5.0.4 and 4.?.?, GD is er..guessing GD2? Not sure.

I'm beginning to think it's my host that's the problem.

I mean, look at this:

http://www.mynimal.net/rss/info.php

PHP version is 5.0.4 and 4.?.?, GD is er..guessing GD2? Not sure.

586264610[/snapback]

I test it with php 5.04 and the latest version of GD2. I don't really see what could be going wrong because that sounds like a php problem, but since your usure about the gd version, i think checking that out is the best route to go.

Make a new .php file with <? phpinfo(); ?> inside to find out.

I also did some slight updates to the code:

-better organization for options

-option to fix the & and " that sometimes show up

I'm done with updating this today, and plan to do the designer thing sometime.

I test it with php 5.04 and the latest version of GD2.  I don't really see what could be going wrong because that sounds like a php problem, but since your usure about the gd version, i think checking that out is the best route to go.

Make a new .php file with <? phpinfo(); ?> inside to find out.

586264748[/snapback]

That's what this is, and what leads me to conclude that my host is having problems. :\

EDIT: Nevermind. I messefd it up, now the phpinfo is working..

GD Version bundled (2.0.28 compatible)

It is likely that it is your host, as the way php acts is controlled by a configuration file, not usually exposed to the host's clients. Despite this, sometimes there are workarounds or ways to temporary change values in the configuration.

Its probably possible to figure out a fix.

I know you said it was on line 48, but i don't have a copy of that version anymore. Could you send me line 48 so i can see what it is?

It is likely that it is your host, as the way php acts is controlled by a configuration file, not usually exposed to the host's clients.  Despite this, sometimes there are workarounds or ways to temporary change values in the configuration. 

Its probably possible to figure out a fix.

I know you said it was on line 48, but i don't have a copy of that version anymore.  Could you send me line 48 so i can see what it is?

586264941[/snapback]

Line 48 is "throw new Exception();", and deals with the error reporting.

Would you make the version with the cut off so it works with my current Neowin RSS one, as my blog titles are never too long, yet the Neowin ones are? Here is the current code, could you add the cutoff to it, as I don't understand all the options on the new version :p

&lt;?
// ******************************************************
//          RSS Feed Script by Benjeeboy on Neowin 
//              Version Customized by TimRogers
//         Shows you the latest forum posts on Neowin
// ******************************************************
// editable:
// $feedurl - the url of your feed
// $imageurl - your background image (if not png change imagecreatefrompng to imagecreatefromgif or other types)
// $fontcolor - the font color
// $fontsize - the font size
// $font - the ttf font file path ex: 'arial.ttf'
// $x - the x position of text
// $y - the y position of text
// $angle - text angle

$feedurl = "https://www.neowin.net/backend.php?page=forum";

$fp = fopen($feedurl,"r");
$contents = ".";
while (!feof($fp))
$contents .= fread($fp,8192);
fclose($fp);

preg_match("#&lt;rss.*?&gt;.*?&lt;channel.*?&lt;item&gt;\s*&lt;title&gt;\s*(.*?)\s*&lt;\/title&gt;#s",$contents,$matchdata);
$title = $matchdata[1];

$imageurl = "http://www.tim-rogers.co.uk/neowinforum/template.PNG";

$img = imagecreatefrompng($imageurl);

$font = 'seguibd.ttf';
$fontcolor = imagecolorallocate($img, 255, 255, 255);
$fontsize = 8;
$x = 65;
$y = 16;
$angle = 0;

imagettftext($img,$fontsize,$angle,$x,$y,$fontcolor,$font,$title);

header('Content-type: image/png');
imagepng($img);
?&gt;

Mynimal, does your feed validate? Also, did you try to take out the "throw new Exception();" line that was causing the problem?

TimRogers, what confuses you about it the new version? - so i can improve it. The options are nearly identical which is why im unsure of why you don't like them. Heres a modified old version with the cut off as per request:

&lt;?
// ******************************************************
//          RSS Feed Script by Benjeeboy on Neowin
//              Version Customized by TimRogers
//         Shows you the latest forum posts on Neowin
// ******************************************************
// editable:
// $feedurl - the url of your feed
// $imageurl - your background image (if not png change imagecreatefrompng to imagecreatefromgif or other types)
// $fontcolor - the font color
// $fontsize - the font size
// $font - the ttf font file path ex: 'arial.ttf'
// $x - the x position of text
// $y - the y position of text
// $angle - text angle
// $maxwidth - the number of pixels of text to display

$feedurl = "https://www.neowin.net/backend.php?page=forum";

$fp = fopen($feedurl,"r");
$contents = ".";
while (!feof($fp))
$contents .= fread($fp,8192);
fclose($fp);

preg_match("#&lt;rss.*?&gt;.*?&lt;channel.*?&lt;item&gt;\s*&lt;title&gt;\s*(.*?)\s*&lt;\/title&gt;#s",$contents,$matchdata);
$title = $matchdata[1];

$imageurl = "http://www.tim-rogers.co.uk/neowinforum/template.PNG";

$img = imagecreatefrompng($imageurl);

$font = 'seguibd.ttf';
$fontcolor = imagecolorallocate($img, 255, 255, 255);
$fontsize = 8;
$x = 65;
$y = 16;
$angle = 0;
$maxwidth=170;

$end='';
$toofarstr='...';
$textbounds = imagettfbbox($fontsize,$angle,$font,$title);
if ($maxwidth != NULL)  // if its not -1, make it fit width-wise
{
	while ( $textbounds[2] - $textbounds[0] &gt; $maxwidth ) //it is wider than maxwidth
	{
  
  $title = substr($title,0,strlen($title)-1); // remove last character
  $end = $toofarstr;
  $textbounds = imagettfbbox($fontsize,$angle,$font,$title . $end);
	}
}

imagettftext($img,$fontsize,$angle,$x,$y,$fontcolor,$font,$title . $end);

header('Content-type: image/png');
imagepng($img);
?&gt;

Anyways, i plan on rewriting alot of it, because as it is i can't do much with it.

Edited by benjeeeboy
Mynimal, does your feed validate? Also, did you try to take out the "throw new Exception();" line that was causing the problem?

I took out that line (new version) and all hell broke loose. :p I also tried removing all instances of the error reporting.

Also, I tried TomRoger's neowin script on my host. It works with the Neowin RSS but not mine.

P.S. It's valid.

//Edit: I just tried another wordpress RSS feed from another blog and I got the same error. It seems to be some sort of Wordpress bug.

Edited by mynimal

My new version is going to be a complete rewrite, and i will try to make it compatible with all feeds and error free.

(Please realise that this is the first time i've written anything in php for ~6 years - when i was 12 so i'm not exactly familiar with it... back then i think it was version 3, now its 5 ;) hopefully i'll catch on soon)

Edited by benjeeeboy

My new feed loader works with your wordpress page.

To make sure that it agrees with your host, try this test script:

&lt;?
	$domdoc = DOMDocument::load('http://blog.mynimal.net/?feed=rss2');
	$xpath = new DOMXPath($domdoc);
	$titles = $xpath-&gt;query('/*/channel/item/title');
	for ($i=0;$i&lt;$titles-&gt;length;$i++)
	{
  echo $titles-&gt;item($i)-&gt;nodeValue;
  echo '&lt;br&gt;';
	}
?&gt;

It should spit out the titles of your posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Google Chrome 149.0.7827.115 (offline installer) by Razvan Serea The web browser is arguably the most important piece of software on your computer. You spend much of your time online inside a browser: when you search, chat, email, shop, bank, read the news, and watch videos online, you often do all this using a browser. Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier. Use one box for everything--type in the address bar and get suggestions for both search and Web pages. Thumbnails of your top sites let you access your favorite pages instantly with lightning speed from any new tab. Desktop shortcuts allow you to launch your favorite Web apps straight from your desktop. Chrome has many useful features built in, including automatic full-page translation and access to thousands of apps, extensions, and themes from the Chrome Web Store. Google Chrome is one of the best solutions for Internet browsing giving you high level of security, speed and great features. Important to know! The offline installer links do not include the automatic update feature. Download web installer: Google Chrome Web 32-bit | Google Chrome 64-bit | Freeware Download: Google Chrome Offline Installer 64-bit | Direct Link | 131.0 MB Download: Google Chrome Offline Installer 32-bit | Direct Link | 119.0 MB Download page: Google Chrome Portable Download: Chrome ARM64 | Direct Link View: Chrome Website | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Oh, it's happening on more than one dialog? This is the dialog that I'm unable to interact with.
    • WSCC - Windows System Control Center 10.0.3.8 by Razvan Serea Windows System Control Center is a free, portable program that allows you to install, update, execute and organize the utilities from various system utility suites. WSCC can install and update the supported utilities automatically. Alternatively, WSCC can use the http protocol to download and run the programs. WSCC is portable, installation is not required. Extract the content of the downloaded zip archive to any directory on your computer. Free for personal use. The setup packages and updates are downloaded directly from their author's website! This edition of WSCC supports the following utility suites: Windows Sysinternals Suite (including support for "Sysinternals Live" service) NirSoft Utilities Mitec and more... WSCC - Windows System Control Center 10.0.3.8 changelog: [NEW] update progress is now visible on the Windows taskbar [FIXED] fixed an issue with the Update dialog [FIXED] minor fixes Download: WSCC (64-bit) | 5.4 MB (Free for personal use) Download: WSCC (32-bit) | 6.3 MB View: WSCC Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • The level of stupidity at Google and Microsoft is beyond belief. All they are doing by killing this is forcing people to jump over to Firefox and ditch them all together, therefore giving Firefox the market boost it needs to finally crush them all in the end.
    • HWMonitor 1.64 by Razvan Serea HWMonitor is a hardware monitoring program that reads PC systems main health sensors : voltages, temperatures, fans speed. The program handles the most common sensor chips, like ITE® IT87 series, most Winbond® ICs, and others. In addition, it can read modern CPUs on-die core thermal sensors, as well has hard drives temperature via S.M.A.R.T, and video card GPU temperature. Special hardware monitors such as abit® uGuru and Gigabyte® ODIN™ power supplies serie are supported too. HWMonitor 1.64 changelog: Intel Arc G3 & G3 Extreme (Panther Lake). Intel Core Ultra 5 250KF Plus (Arrow Lake Refresh). AMD Ryzen 7 7700X3D (Raphael). AMD Ryzen AI Max+ 495, 492, 488 (Gorgon Halo). AMD Ryzen AI Max 490, 485 (Gorgon Halo). AMD Ryzen AI Max PRO 495, 490, 485, 480 (Gorgon Halo). AMD Ryzen 9 9950X3D2 (Granite Ridge). AMD Ryzen 9 PRO 9965X3D, PRO 9945 (Granite Ridge). AMD Ryzen 7 PRO 9755, PRO 9745 (Granite Ridge). AMD Ryzen 5 PRO 9645 (Granite Ridge). AMD Ryzen AI 7/PRO 450G/GE (Gorgon Point 2). AMD Ryzen AI 5/PRO 440G/GE (Gorgon Point 2). AMD Ryzen AI 5/PRO 435G/GE (Gorgon Point 3). Support of HUDIMM and HSODIMM memory modules. New themes. New real-time graphs. Download: HWMonitor 1.64 | 3.4 MB (Freeware) Download: Portable HWMonitor 1.64 | 2.7 MB View: HWMonitor Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Month Later
      Clizby earned a badge
      One Month Later
    • One Month Later
      Timaximus earned a badge
      One Month Later
    • Week One Done
      Timaximus earned a badge
      Week One Done
    • Rookie
      FBSPL went up a rank
      Rookie
    • First Post
      davidbazooked earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      495
    2. 2
      PsYcHoKiLLa
      171
    3. 3
      +Edouard
      163
    4. 4
      Steven P.
      86
    5. 5
      ATLien_0
      77
  • Tell a friend

    Love Neowin? Tell a friend!