Divide by zero
 Tuesday, August 12, 2008
Media RSS (MRSS) and PicLens support in a web page

Media RSS (MRSS) is an XML format which extends the RSS format. By using this format, a website can be enabled to provide rich media functionality. This can be used for images, audio and video. This entry discusses enabling Media RSS for images. Video is very easy to implement, but will not be discussed here. By using PicLens in Firefox, the result looks like below. It is very fast, full screen, and has nice facilities to scroll around the images, zoom in and out and other such things. Here I will discuss a simple implementation, and you can scroll below to download a small .NET application to automate this process. If you already have a Media RSS viewing application, then check out an example of the output (Note, copyright links were added after the page was generated).


How to implement Media RSS

The Media RSS format is very simple, it only requires the addition of two namespaces to an RSS feed, and two elements within that namespace. The namespaces are:

xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:media=http://search.yahoo.com/mrss/


The elements that need to be added are:

<media:thumbnail url="path_to_image_thumbnail" />
<media:content url="path_to_image" />

The URL's can should be absolute URL's to validate in feed validation systems, although it will still work if you use relative URL's. The thumbnail element should be used, but if you don't have a separate thumbnail image you can just point it at the same as the full size image. It would be worthwhile to use a thumbnail as you will save bandwidth and probably please your viewers with a more responsive experience.

The last thing to do is to include a link to the feed on the page where you want to display it. This points to the Media RSS feed you created earlier. The Media R

SS feed can exist anywhere in your site, just make sure you point to it in the page where you want the feed discovered.

<link rel="alternate" href="imagegallery\media.xml" type="application/rss+xml" />

Automatic generation of Media RSS

I have included a download of an application to generate all the files necessary to implement Media RSS on a site. This is an update to an earlier application called Focas.net.ImageGallery. This application creates a MooTools/Prototype image gallery. This update adds a Media RSS file and appropriate link to it. The download link is below. The information describing the images is extracted from the image itself. There is an earlier blog entry describing how this is done, or you can also refer to the metadata section below.


Using the application

To use the application, you need to start the application and do the following:

  • Choose the image directory
    Note: Only images of type jpg,jpeg,gif and png will be used, and only images in the root of this folder.
  • Output directory
    Any existing files in this folder will be overwritten. The folder will not be cleared out first if any files exist.
  • Title
    This will be the title of the page, the heading above the images of the Image Gallery, and title of the Media RSS feed.
  • URL
    This is optional. If you want to put the files up on a web server then this would be the path up to where you put the gallery. If you omit it, then the paths to images will be relative. This may result in feed validators claiming the feed is invalid, but it will work anyway. It is worth leaving this blank For the first attempt, so that you can see what the gallery looks like from the local file system.
  • Folder for images
    This is the name of the folder where the actual pictures will be stored. The default if empty will be pictures.

Once you click Make the gallery! all the necessary files will be created, and automatically displayed in internet Explorer. Note that the images will not work properly in PicLens if an URL was specified as the paths are absolute URL's. The files are now ready to upload to your web server.

A note about metadata and troubleshooting

Metadata is data describing something. In this case, describing the images. This metadata is extracted from the images themselves. If using Windows Vosta then this information is easily entered via Windows Explorer or the standard picture viewer application. On previous versions of Windows, you can download the Microsoft Pro Photo tools, a free download from the Microsoft site. If you have no metadata for your images, then the application will still generate a Media RSS file, but it is better to use some metadata.

Additional resources

PicLens WebMasters guide
Microsoft Pro Photo Tools
PowerSet Media RSS links

Downloads

Source code (.NET) (89.9 KB)

Executable(140.5 KB)


Tuesday, August 12, 2008 11:18:03 PM (AUS Eastern Standard Time, UTC+10:00)   #    Comments [0]  Downloads | JavaScript | Metadata | Programming | Webmaster
link to del.icio.us link to reddit link to StumbleUpon link to Facebook Bookmark to Google
 Wednesday, July 30, 2008
Moodle file upload and SCORM problems
I have been doing some work with the excellent Moodle, an open source Learning Management System, and after doing an upgrade, started experiencing problems uploading SCORM objects. The specific errors I was getting were PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature, and An error occurs during package unzip (sic). After a lot of searching, it seemed a few people were having similar issues, and mostly it seems Internet Explorer was being blamed. Perhaps there is also a problem with Internet Explorer, however in my case, I ended up working out where Moodle stores the files on the server and inspected the folder. The file was corrupt, I couldn't download the zip file.

After trying to manually upload the files I discovered that the disk quota had been exceeded. After doing a cleanup of the disk, everything worked well.

Sometimes when searching for the cause of a problem some facts eclipse our abilities to be a little objective about the true nature of the problem. In my case it seemed clear that the problem occurred as soon as I upgraded, when in reality the cause was my making a backup on a full server. This could have been avoided in a few ways. Firstly I should keep an eye on the server quotas, that should have been a give away. However, I think the Moodle developers should have caught an IO exception when the disk was full, and reported back to the browser. This would have saved a lot of time. Having said that, I am very impressed with Moodle, this is just one of those habits that happen a lot in programming where such potential errors as stack overflow, out of memory, or IO errors are ignored with an optimistic hope that they should never occur. With this error, I assume something worse is happening. Because the page didn't crash with an error, I can only assume the error was swallowed, and thus vital helpful information was never presented on the web page.

As soon as I have caught up with this work I will look at the code and see if I can offer a bug fix.

Update: I have also experienced problems doing a course backup, with the same root cause, not enough disk space. When doing the course backup, the messages received are An error occurred while backing up course start and An error occurred while copying the zip file to the course directory. After looking at the code, it appears the Moodle error handling only looks for 4 types of IO errors. PHP 5 has 7 types, I believe it is the type 7 error that would cause this. Unfortunately the error trapping routine has a default handler for unknown error types.


Wednesday, July 30, 2008 4:24:06 PM (AUS Eastern Standard Time, UTC+10:00)   #    Comments [0]  Moodle | Programming | Webmaster
link to del.icio.us link to reddit link to StumbleUpon link to Facebook Bookmark to Google