Pappmaskin.no / DIY our die
×

Code: Delicious.com + Thumbalizr screenshots + caching

Published mars 20th, 2010 by

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=10
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
}
 
}
 
?>

(mer…)

Posted in Code

Delicious Screenshots – my first wordpress plugin

Published oktober 21st, 2008 by
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /customers/7/5/b/pappmaskin.no/httpd.www/wp-content/plugins/delicious_screenshots/wp_delicious_sceenshots.php on line 75 Warning: file_get_contents(http://feeds.del.icio.us/v2/json/mskogly/art?Fcount=6): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /customers/7/5/b/pappmaskin.no/httpd.www/wp-content/plugins/delicious_screenshots/wp_delicious_sceenshots.php on line 75 Warning: Invalid argument supplied for foreach() in /customers/7/5/b/pappmaskin.no/httpd.www/wp-content/plugins/delicious_screenshots/wp_delicious_sceenshots.php on line 79

If this works there should be about 6 thumbnails on this page, showing links bookmarked using Delicious, and tagged with «art».


Download:
Download delicious_screenshots.zip here, version 0.7 of my very first wordpress plugin.

Usage:
Activate plugin. And add your del.icio.us username to the options page. (under settings in the WordPress toolbar)
https://i2.wp.com/pappmaskin.no/wp-content/2011/07/20081020-jq6mtqhq3k4pu475bffhjuppcs.jpg

Changelog:
14.02.2017: Changed from rss to json and cleaned the code up a bit. Also removed Snapcasa from options.

What’s next:

  1. The first version of this plugin used Snapcasa for creating thumbnails, but I switched to thumbalizr.com to get a higher success rate.
  2. The count param doesn’t seem to do anything when calling the del.icio.us api, it always returns 10 results, so I need to handle that in the code instead. I’ve notified them of the bug.
  3. Testing other screenshotting services or making my own.
  4. Choosing an image from the page metadata when available.

Posted in Code, Open Source

Playing with SnapCasa screenshots and del.icio.us

Published oktober 17th, 2008 by

https://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)

(mer…)

Posted in Code, Open Source

Open source flash-based sound sequenzer

Published september 26th, 2008 by

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.

Posted in Art, Code, DIY, Flash, Open Source, Portfolio

Happy birthday to GNU!

Published september 3rd, 2008 by

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
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
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!

Posted in Personal

Bomber Jack Clone

Published september 8th, 2003 by

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!

Posted in Flash, NRK, Open Source, Portfolio