Archive for the 'Open Source' Category

Laconica, PHP5, and GD Woes - and a quick patch!

Tim July 26th, 2008

So, I’ve been playing around a bit with Laconica, an open source micro-blogging engine used to power Identi.ca.  I finally have it up and running smoothly, however, I’ve found that the “official” installation documentation is a bit sparse and missing a few steps and dependencies.  Because of this, a few snags in the setup process had me scratching my head.  What did help me immensely in the process is the following blog entry on 0xDECAFBA - Getting Laconica up and running.

The problem I ran into was with the avatar upload.  When I tried to upload my avatar, I would be greeted with a blank page (the “oh-crap-internal-server-error-where’s-my-whiskey” kind of blank page).  I opened up my /var/log/httpd/error_log to seek out what exactly occurred.  Here’s what I found:
[Wed Jul 23 13:01:55 2008] [error] [client 10.6.132.139] PHP Fatal error: Call to undefined function image_type_to_extension() in /var/www/html/laconica/classes/Profile.php on line 85, ...

Interesting.  My brand new fancy avatar is now reduced to a broken image in Laconica.  To revert back to the default gray and apathetic face avatar, simply remove all entries in the avatar table of your Laconica DB instance.

Some quick background about the configuration:

$ uname -srvpio
Linux 2.6.18-92.1.6.el5PAE #1 SMP Fri Jun 20 02:51:01 EDT 2008 i686 i386 GNU/Linux

$ php -version
PHP 5.1.6 (cli) (built: Jun 12 2008 05:02:35)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

A fairly recent setup.  Since this was a fresh install, I figured something had to be wrong with the installation of the PHP GD libraries.  Naturally the next step would be to do a var_dump(gd_info()); to confirm any issues:
array(12) {
["GD Version"]=>string(27) "bundled (2.0.28 compatible)"
["FreeType Support"]=>bool(true)
["FreeType Linkage"]=>string(13) "with freetype"
["T1Lib Support"]=>bool(false)
["GIF Read Support"]=>bool(true)
["GIF Create Support"]=>bool(true)
["JPG Support"]=>bool(true)
["PNG Support"]=>bool(true)
["WBMP Support"]=>bool(true)
["XPM Support"]=>bool(false)
["XBM Support"]=>bool(true)
["JIS-mapped Japanese Font Support"]=>bool(false)
}

Nope. Everything looks fine with the setup.  And according to PHP.net, image_type_to_extension() should be available for >=PHP5.0.  This, however, doesn’t appear to be the case.  As Chris notes:

Function was added in PHP 5.2, not PHP 5 (you would assume this means 5.0)

So, evidently, my current version of PHP (and the most recent in the RHEL5 repos) does in fact not support the image_type_to_extension() function. If you have the most recent version of PHP, you should be fine.  If not, here’s the fix: To work around this issue, I devised a simple modification that would overwrite the image_type_to_extension() functionality if you’re experiencing the same issues. Head to $LACONICA_HOME/classes/, back up Profile.php, and then open it up in your favorite editor. Head to Lines #84 and #85 $filename = common_avatar_filename($this->id, image_type_to_extension($info[2]), NULL, common_timestamp()); and replace it with the following code snippet below:

# Start - More RAM.
if(function_exists(image_type_to_extension))
{
$extension = strtolower(substr(image_type_to_extension($info[2]),1));
}
else
{
list(,,$imageType) = getimagesize($image);
switch($imageType)
{
case IMG_GIF:
$extension = ".gif";
break;
case IMG_JPG:
$extension = ".jpg";
break;
case IMG_PNG:
$extension = ".png";
break;
}
}
$filename = common_avatar_filename($this->id,$extension,NULL, common_timestamp());
#END - More whiskey.

Save Profile.php, and now try to upload a new avatar. Problem fixed!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Geospatially Visualizing Users’ Preferences from APML Profiles

Tim April 11th, 2008

So, I’m getting some abuse from friends and colleagues for not updating my blog. Between grad school and work, I’ve found there’s little time to write entries! I’m sitting here in a hotel room in New Brunswick, NJ waiting for the new Office to come on, so I have some free time for the moment…

But here’s something that people may find interesting. For my INFO633 (Information Visualization) class at Drexel, I developed a framework for tracking trends and patterns in Google Earth based on concepts captured from APML profiles. This is my initial research in the feasibility of the idea, spanning about four weeks of work. I submitted it to the IEEE Information Visualization 2008 conference for review out of interest for understanding the call for papers process.

I’m a huge fan of DataPortability and am actively seeking areas where regular (non-technical) users will find value in the concepts and principles outlined by the initiative. Possibly a project for the DataPortability Labs?

Download the file here (11.3MB PDF warning).

Development is on-going. Comments welcome!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

APMLStream 0.1 Released!

Tim January 20th, 2008

APMLStream is a Java library that allows developers to easily serialize and deserialize Attention Profiling Markup Language (APML) data within full compliance of the APML specification (currently 0.6). This makes editing, merging, and querying APML files in an object-oriented environment extremely easy.

APMLStream uses the XStream and XML Push Pull Parser libraries, and is currently released under the Apache License 2.0.

You can browse the source here at Google Code, or checkout and build the source from SVN:  svn checkout http://apml-library.googlecode.com/svn/trunk/Java/APMLStream/APMLStream-0.1/ apmlstream-src

To build the source, you’ll need the Java 6 SDK and Apache Ant.  I’m using the most recent Java SDK (1.6.0_04) and Apache Ant (1.7.0).  Building is as simple as issuing the following commands in your terminal:  ant, ant jar, ant javadocs.  Then, include the apmlstream-0.1.jar into your project, and you’re done!  I’ve also provided the binary distribution with this post.

Although I still have a laundry list of to-do’s for this library, v0.1 contains the basic functionality for APML data manipulation. Expect an APMLStream tutorial within the next day or so! Comments and suggestions are also welcome.

Downloads:apmlstream-0.1.jar apmlstream0.1-javadocs.zip

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]