cgi-bin scripts for the Photo Wall #1

I mentioned in my previous blog that performance of HTML5 canvas on a Raspberry PI is not something to impress that much; not at all. And this was something I had in my mind from the beginning and my hope was that it might still stay acceptable if I’d use smaller photos, having just the size I need when I display them on the screen instead of the n MP the original photos have.

Which means, the JS code should not directly load the Images in their original size, but scaled version of them. In order to efficiently scale photos (and do a lot of other “tricks” with photos), there exists GraphicsMagick. Now if we bring together the requirement to deliver images to a browser with the need to execute (as a script) GraphicsMagick the solution to write cgi-bin scripts comes into one’s mind quite soon.

You may find in GitHub the first version of WallJS cgi-bin to reduce the size of the displayed images + to randomly add frame and border. See 2 examples of its output here below:

p6p7

I developed / tested this on my mac, after installing (brew) GraphicsMagick on it. In order to test cgi-bin on Mac you can place the script in a folder called cgi-bin, make the script executable, and then start a test python WebServer. See the source in GitHub for more details on how to make it work. I assume this works also on a “regular” Linux machine, but of course, I’d not recommend you to run it on the same PI as the Photo Wall as you might get performance problems. In case you try it on the PI, please share your findings.

You may call the script as: http://localhost:8000/cgi-bin/getPic.sh?450:123 where the first parameter is the expected height of the returned image and the second parameter is a random number to prevent that the browser caches the image after the first call and does no further calls to the script, when called from WallJS page.

Before finishing this page let me once again clearly say it: this is a Proof of Concept and nothing more. It provides NO protection in terms of security and I definitely NOT recommend you to run this script on a computer which can be accessed from Internet or from an insecure Intranet. Notice the license terms and the readme and use it ONLY if you know what you’re doing.

PS: See here if you are interested to make this work on a Synology DiskStation.

For any questions, bug reports, suggestions, use the appropriate thread in the Raspberry PI forum.

Advertisements
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: