Topic: Image viewer from USB drive

A net-less picture frame application would be cool... just playing images off a thumb drive.


It seems like an obvious thing to expect form a device with a screen and USB ports... even my phone does it.  It does clash a bit with the architecture, though.  I think if Chumby ends up in retail stores this would play well, as there are similarly priced devices that do ONLY that.  And you could show them up with options options like touch-zoom and panning by rotating it in your hand.

2 (edited by skellener 2007-12-13 08:35:01)

Re: Image viewer from USB drive

Or even pics off your iPod.  I mean, if it can read the music files, why not the pics?

Re: Image viewer from USB drive

Currently, the ipod library isn't linked with libjpeg, so the current firmware can't show the images although the protocol is supported.

For general "images on a dongle" it's a lot about image size and format.  If you stuck raw images from a 8 megapixel camera onto a USB dongle and tried to load them into Flash, you'd run out of memory instantly.  We'd need to have some sort of firmware executable that could resize and transcode images on the fly without loading them into memory in their entirety.  Also, many cameras produce images in TIFF, which we don't currently have support for.

Re: Image viewer from USB drive

Ahh...I see.  Well maybe at some point it will happen.

If it could simply read images on a USB key, just let us know the spec?  320x240 JPGs?

Re: Image viewer from USB drive

320x240 JPEG is best for this.

I have a little movie that I run off a dongle that plays such images from the dongle - pretty easy to do.  I use iPhoto to export the files in the correct size - most image management tools have this ability.

Here's some handy AS1 code that can be used to find the files:

//
// Name: FileFinder.as
// Author: Duane Maxwell
//
// Copyright (c) 2007, Chumby Industries
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of Chumby Industries nor the
//       names of its contributors may be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY CHUMBY INDUSTRIES ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL CHUMBY INDUSTRIES BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Usage:
//
// finder = new FileFinder("/mnt/usb");
// finder.matchFunction = function(file) { return true; };
// finder.target = this;
// finder.completionFunction = function(files) { trace(files); }
// finder.find();

_global.FileFinder = function(rootDirectory) {
    this._protocol = "file://"; // the protocol we're using
    this._directories = [ rootDirectory ];
    this._files = []; // the array that will hold the file paths
    this._dirXML = new XML(); // the XML object that will be used to traverese the directories
    this._dirXML.ignoreWhite = true;
    this._dirXML.__target = this;
    this._dirXML.onLoad = function(success) {
        if (success) {
            this.__target.processDirectory(this.firstChildOfType('directory'));
        }
        this._dirXML = undefined;
    }
}

//
// for each directory read, collect the matching files, and append any subdirectories to the queue, then
// search the next directory in the queue.  If the queue is empty, start processing the files.
//
FileFinder.prototype.processDirectory = function(dir) {
    var base = dir.attributes.path;
    var fileItems = dir.childrenOfTypeAnd('file',this.matchFunction);
    for (var i in fileItems) {
        this._files.push(base+'/'+fileItems[i].attributes.name);
    }
    var dirs = dir.childrenOfTypeAnd('directory',function(d) { return d.attributes.name.charAt(0)!='.'; });
    for (var i in dirs) {
        this._directories.push(base+'/'+dirs[i].attributes.name);
    }
    if (!this.find()) {
        this.completionFunction.call(this.target,this._files);
    }
}

//
// process the next directory in the queue, return false if none available
//
FileFinder.prototype.find = function() {
    if (this._directories.length>0) {
        var dir = this._directories.pop();
        this._dirXML.load(this._protocol+dir);
        return true;
    }
    return false;
}

The apparently scary license is actually BSD, so you're free to use the code in your own projects.  It takes advantage of a extension we made to the Flash Lite player that returns XML when you do XML.load on a directory. It will only work for movies running locally, not normal widgets that come in over the network.

Replace the match function to only return true for jpg files.  At that point, it's just a matter of loading them in succession.

Re: Image viewer from USB drive

I use a little chunk-o-AppleScript to resize and crop to fill an arbitrary screen size.

Preprocessed like that, you could fit a butt-load on a smallish dongle.