Tag Archives: Open Source

Code: Delicious.com + Thumbalizr screenshots + caching

I’m playing with my Delicious Snapcasa code this weekend to see if I can replace Snapcasa with the thumbalizr.com screenshot-service. Snapcasa was great because it gave me plenty of free captures each month, but it has some serious problems capturing some of the sites I throw at it, and was behaving rather randomly, so it has to go.

I’ve looked at several screen shot services, and tested many, and so far it is thumbalizer.com that seem to be the fastest and most stable, and the free version is able to take screenshots of webpages deeper into the site, not just the front page. As far as I can see I can’t find any limit on the api, but the free version does have a watermark on each thumb. I’m too cheap to spring for a paid account, but you do have that option.

The result so far

Demo: http://pappmaskin.no/opensource/delicious_snapcasa/delicious_thumbalizr.php?tag=art&count=100
Shows: The last 100 bookmarks tagged with “art” on delicious.com by me.

Caching

Thumbalizr.com provides a .gz with some php for caching the thumbnails their API provides, but I wasn’t able to get it to work last night. Luckily Anton Lindquist has branched the code on GitHub and made some improvements, and after a little headscratching (aka googleing) and some helpful tips from Anton himself, I am now running a version that grabs the images from Thumbalizer and stores them locally on my server, speeding up the pages quite a lot, easing the stress on thumbalizer, and most importantly, preventing already grabbed pages from being queued again and again.

New default queue image

Thumbalizr provides an OK queue-image while their services works on grabbing a screen shot of the page you request but with some help from Anton I’m not using my own custom image, currently a picture of my son holding a fish (just to make him smile :). It’s nice to have a little more control over what is displayed on the page until the image is ready for use, especially when you do like me and fire off a grid of many screen shots on the same page.

Possible uses

I’ve rewritten my original Snapcasa script into a WordPress plugin which I use on several of my blogposts right now. I’ve also made a standalone page for my sons, a start page with kid friendly games and YouTube-videos etc. They can’t read yet, so it’s nice to have an automated start page with pictures.

The code

I promised to update this post with the code I use for working with the Thumbalizr api and caching images locally. As I said I use this caching script instead of the code provided by Thumbalizr. It comes with an example index.php, that I’ve expanded on a little. Right now it looks like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 'api_key',
	'local_cache_expire' => (!$config['local_cache_expire']) ? 3600 : $config['local_cache_expire'],
 
);
$image = new thumbalizrRequest($config);
 
$image->request($imageurl);
 
//$image->request('http://www.thumbalizr.com/');
 
if($image->headers['Status'] == 'OK' || $image->headers['Status'] == 'LOCAL') {
	$image->output();
} else {
	//print_r($image->headers); //debug
//http://pappmaskin.no/wp-content/2010/03/noah-2624545080_417ba06836_m.jpg
 
$filename = 'http://pappmaskin.no/wp-content/2010/03/noah-2624545080_417ba06836_m.jpg';
$size = getimagesize($filename);
$fp = fopen($filename, "rb");
if ($size && $fp) {
    header("Content-type: {$size['mime']}");
    fpassthru($fp);
    exit;
} else {
    // error
}
 
}
 
?>

Continue reading

Delicious Snapcasa – my first wordpress plugin

Update: Due to spotty performance from Snapcasa I’m currently working on switching to another screenshot service. Read about it here.

Whiiiiiiiiiiiiiii! If this works there should be about 6 thumbnails on this page, showing links bookmarked using Delicious, and tagged with “art”.

Screenshot for http://www.ted.com/talks/golan_levin_ted2009.html

Golan Levin makes art that looks back at you | Video on TED.com

Screenshot for http://www.swimmingcities.org/

SWIMMING CITIES OF SERENISSIMA

Screenshot for http://vimeo.com/18572203

ZEIGER on Vimeo

Screenshot for http://www.ted.com/talks/jr_s_ted_prize_wish_use_art_to_turn_the_world_inside_out.html

JR's TED Prize wish: Use art to turn the world inside out | Video on TED.com

Screenshot for http://www.etsy.com/listing/15551945/japanese-maple-bonsai-barbie-tree-one-of

JAPANESE MAPLE BONSAI BARBIE TREE by by 2LaVonne

Screenshot for http://en.wikipedia.org/wiki/Giclée

Giclée - Wikipedia, the free encyclopedia


Download:

Download wp_delicious_snapcasa.zip here, version 0.5 of my very first wordpress plugin.

Usage:

http://i2.wp.com/pappmaskin.no/wp-content/2011/07/20081020-jq6mtqhq3k4pu475bffhjuppcs.jpg?w=625

(ps, right now you have to hack it if you want to see your own bookmarks, mskogly is hardcoded  :) Working on that :)

What’s next:

I’m considering a few other thumbnailing services:

http://www.thumboo.com/

http://webthumb.bluga.net/home

http://www.pageglimpse.com/

http://www.scurlr.com/

Playing with SnapCasa screenshots and del.icio.us

http://i0.wp.com/pappmaskin.no/wp-content/2011/07/20081016-es6718uspgixxfa8x8d7kbqm8y.jpg?resize=480%2C354

Tonights nerdfest will include trying to use the SnapCasa and del.icio.us to generate a lovely page full of thumbnails, one for each url.

Ingredients:

1. My 100 latest bookmarked urls from del.icio.us: http://feeds.delicious.com/v2/rss/mskogly?count=100
2. A SnapCasa login account.
3. A server that supports xslt transformation. (I’m running MAMP on my macbook, and pappmaskin is hosted on One.com)
4. A text editor. I’m using Dreamweaver for this, since it has some pretty good tools for building xslt. (Take a look at the Adobe Livedocs for more info on using it).

(More after the break)

Continue reading

flash sound sequenzer Screenshot

Open source flash-based sound sequenzer

I’ve been thinking alot about making a soundbased installation in Adobe Flash, using sensors and switches, and I’ve gotten around to making a few small eksperiments/prototypes as research, which I’m planning to share on this site later.

But I also found this old experiment I wrote in Flash 5 (!) and wanted to share it. It is a visual sequenzer (*) / sound toy that lets you drag icons onto a “soundstage”, each icon representing a sample. As you press play a line starts moving vertically, and as the line hits one of the icons, the corresponding sound is played. You can also click, drag and hold an icon, and move it on top of the moving line to trigger the sound. There are two types of sounds. The yellow icons trigger different “wet finger on glass” sounds, and the greywhite icons trigger sonar ping sounds.

Open Source

The code is pretty old, and there are WAY better ways of making something like this with AS3, but still, here is the source code (fla) for it (it also includes the samples, which you are free to use in any way you like).

I still think it is a pretty nice little project, but I am toying with the idea of replacing the click and drag with a webcam mounted in the ceiling, and letting people moving around on the floor trigger the sounds. I have quite a lot to learn before I can make something like that, but I’ll get there!

* Ok, so I guess it is a stretch to call this a sequenzer, but I wanted to create a fun, easy and interesting way to generate a sound collage.

Happy birthday to GNU!

Just got a heads up that the wonderful people over at GNU used one of my pictures in their Happy Birthday to GNU-video. I am of course a big fan of open source in all shapes and forms, so this is simply an honor and a delight! I said jokingly to my wife that “it felt like as if the Dalai Lama had quoted me”, which of course is a SLIGHT exaggeration, but you get the point. I am not a great photographer, so when someone, anyone wants to use an image it simply makes me REALLY REALLY HAPPY!

See the video below, or go to http://www.gnu.org/fry/ to view or download the original.

It’s probably a coincidence, but this is the third time in just a few months where someone has used one of my images in some way. They are all on flickr.com and they all have Creative Commons licences, most of them for commercial use as well, making it easy for anyone to use them as they wish. I am not a professional photographer, so I really have no urge to sell them. If anyone want to use them, then fine!

So, these are the images that people have picked:

Hesttrøa 7 - New bathroom project
photo credit: mskogly

Now, this image of my plumbing is just awful, and I suppose that was the point. I took it as documentation before renovation, it sure ain’t art. But still, it is wonderful to be wanted!

River Walk, San Antonio, Texas
Creative Commons License photo credit: mskogly

The San Antonio River Walk is quite a sight, it was a big surprise to find such a lush place in the middle of the city, and after having my senses numbed by the wasteland of the US highway system. A small version of this image is in use on a site called Scmap, go to
www.schmap.com/sanantonio/tours_tour3/p=2048D03/i=2048D03_10.jpg and take a look in the right hand corner. The image was also printed in the Fifth Edition of the Scmap San Antonio Guide. Schmap also makes their guide available in widget form, letting you embed the guide in your blog etc, looks something like this.

And the last image so far:

Highway, Houston
Creative Commons License photo credit: mskogly

This Highway-picture was used in an article about Houston in an online magazine for expatriates called Global Connection. I don’t have access to it, so I don’t know what the finished article looks like.

The open source principle VS. the need for an income
I have followed a few debates about how “amateur photographers” encrouch on the livelihood of professionals, making it harder to make a living. There might be some merit to this, but I also believe that there is room for both. The access to cheap or free images makes it easier for more people to create, to write about and promote good things. Just like Google Maps and other map apis created an explosion in new services and mashups, sites like Flickr with a well organized way to search for pictures published with a suitable creative commons licence will lead to a richer flora of online and printed works. And I believe that the work will be a better world for it. Imagine the price of creating a school textbook “in the old days”, it would cost a small fortune in royalties for the images used, often images used purely as illustration of a concept (like pollution). These days, a writer, teacher or pupil for that matter could do a quick search on Flickr and find just about anything they need, for free, and with the permission to use the material in eighter a commercial or non-profit setting. Magic!

Podcastplayer in flash! Php script to convert RSS to XSPF

Big Sound, Little Ears

photo credit: …Tim

Create your own free flash based podcast / mp3 player

I like the flashbased XSPF mp3 player. I had planned to rewrite the actionscript so that it could read rss with enclosures instead, but I liked the possibility to have unique pictures on each track, and I wanted to check out the XSPF format.

So I wrote a PHP script that uses DOMXML and xpath to convert an existing rss to xspf, it even have a search function of sorts.

I’m going to use it on a project I’m working on after a little more tweaking but I wanted to share it with other people who has a podcast and want a quick open source way to present their podcasts on their website.

Localino meets elePHPant
photo credit: Chregu

<?php

$path = “http://podkast.nrk.no/program/radioresepsjonen.rss”;

$showfile = file_get_contents($path);

if(!$doc = domxml_open_mem($showfile)) {

echo “Error while parsing the document…”;

exit;

}

$xpath = xpath_new_context($doc);

$root = $doc->document_element();

//debugging

//echo domxml_version();

//var_dump(xpath_eval_expression($xpath, ‘/rss/channel/item’)); //http://no.php.net/manual/sv/function.xpath-eval-expression.php

//debugging – memory dump

//echo $doc->dump_mem( true, ‘UTF-8′ ) ; //http://no.php.net/manual/sv/function.domdocument-dump-mem.php

//print ” Path: <a href=\”$path\”>$path</a><br>\n”;

//print ” Showfile: <a href=\”$showfile\”>$showfile</a><br>\n”;

//print ” domDoc: <a href=\”$domDoc\”>$domDoc</a><br>\n”;

//print ” root: <a href=\”$root\”>$root</a><br>\n”;

// playlist plus search function

$playlist = $xpath->xpath_eval(“/rss/channel/item[contains(translate(title,'abcdefghijklmnopqrstuvwxyzæøåö', 'ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅÖ'), '".strtoupper($_REQUEST["search"]).”‘)]”);

//debug

//print “playlist found: “.count($playlist->nodeset).”\n”;

print “<?xml version=\”1.0\” encoding=\”UTF-8\” ?>\n”;

print “<playlist version=\”0\” xmlns=\”http://xspf.org/ns/0/\”>\n”;

print ” <title>Put clever title here, or get it from the rss</title>\n”;

print ” <annotation>Description of some sort</annotation>\n”;

print ” <creator>Who made this</creator>\n”;

print ” <info>http://link to more info</info>\n”;

print ” <location>http://yourdomain.com/doesnreallymatter/rss2xspf.php</location>\n”;

print ” <license></license>\n”;

print “<trackList>\n”;

foreach ($playlist->nodeset as $tracklist) {

$description = “”;

$title = “”;

$enclosureurl = “”;

//$enclosureurl = $tracklist->get_attribute(“length”);

//$spor = $tracklist->get_attribute(“spor”);

//$sangid = “$arkivnr-$spor”;

foreach ($tracklist->child_nodes() as $child) {

if ($child->node_name() == “title”) $title = $child->get_content();

if ($child->node_name() == “description”) $description = $child->get_content();

if ($child->node_name() == “enclosure”) $enclosureurl = $child->get_attribute(“url”);

}

print “<track>\n”;

print ” <location>$enclosureurl</location>\n”;

print ” <image>hassan/bilder/else150.jpg</image>\n”;

print ” <annotation>$title</annotation>\n”;

print ” <info></info>\n”;

print ” <info_text>$description</info_text>\n”;

print ” </track>\n”;

}

print “</trackList>\n”;

print “</playlist>\n”;

?>

Copypaste the above code into a new file and save it as rss2xspf.php and upload it to your server to test if you have domxml support. (If you don’t it will say something like Call to undefined function: domxml_open_mem. In that case, tough luck, find a new host.)

Download the exellent XSPF flash based mp3 player here: XSPF Web Music Player (Flash) – Plays MP3 on your website

Read more about XSPF over at http://www.xspf.org/

And please drop a comment if you use it and like or have problems.

You can also send me an email at morten.skogly _at_ gmail dot com.

There’s a lot of room for improvement, like using the rss image in place of a staticly defined image, or inserting a random image, or doing som web2.0 stuff like snarfing the images from amazon or whatever, please let me know if you make something superclever with it :)

Idea for your site: You can use del.icio.us to make your own mp3 podcast, visit bands you like bookmark the mp3s you like with del.icio.us, go there to get the rss, and your set to go, you have the same music on your site as on your ipod :) (You might have to use feedburner.com as a gobetween to create the enclosures and make it itunes-compatible.)

Updated: 06.04.2008: Unless you really really digg the XSPF player linked up above, I suggest you use the superb Jeroen Media Player instead. It is open source and supports both XSPF and RSS directly. It takes up more space, but it has video support and a very cool javascript api.

SourceForge.net: Project Info – MeWiG – MEncoder GUI for Windows

This and mencoder is the only open source video converter I’ve come across that can, in theory, output H.264 for the ipod, in addition to a huge variety of other formats. Videolan also has some interesting possibilities. Both are a little nerdy to set up, but hey, I’m feeling nerdy.

SourceForge.net: Project Info – MeWiG – MEncoder GUI for Windows:

MeWiG is a Windows Frontend to the MEncoder (part of MPlayer) using the .NET Framework. You should be able to crop, scale, deinterlace, etc and finally convert almost any digital video-source, without the need for commandline-options.

On Del.icio.us: , , ,

Bomber Jack Clone

Valgfleskspillet

I spent a few weeks creating a Bomber Jack clone from scratch for a radio show at NRK, and ended up reskinning it at least 3 times for other projects (easy money). This version was made for the Norwegian election in 2003.

Valgfleskspillet.

And here is a screenshot from another clone, made for the childens pages at NRK:

Hopp med Fantorangen

Want the code? Drop me a line!