rox.thumbnail
index

Interface to the thumbnail spec.  This provides a functions to look up
thumbnails for files and a class which you can extend to generate a thumbnail
image for a type of file.
 
The thumbnail standard is at http://jens.triq.net/thumbnail-spec/index.html

 
Classes
       
Thumbnailer
GdkPixbufThumbnailer

 
class GdkPixbufThumbnailer(Thumbnailer)
      An example implementation of a Thumbnailer class.  It uses GdkPixbuf
to generate thumbnails of image files.
 
  Methods defined here:
__init__(self)
get_image(self, inname, rsize)

 
class Thumbnailer
      Base class for programs which generate thumbnails.
 
The method run() creates the thumbnail for a source file.  This
calls the methods get_image(), process_image() and store_image().
process_image() takes the image returned by get_image() and scales it to
the correct dimensions then passes it through post_process_image() (which
does nothing).
 
You should  override the method get_image() to create the image.  You can
also override post_process_image() if you wish to work on the scaled
image.
 
  Methods defined here:
__init__(self, name, fname, use_wdir=False, debug=False)
Initialise the thumbnailer.
name - name of the program
fname - a string to use in generated temp file names
use_wdir - if true then use a temp directory to store files
debug - if false then suppress most error messages
creation_failed(self, inname, outname, rsize)
Creation of a thumbnail failed.  Stores a dummy file to mark it
as per the Thumbnail spec.
get_image(self, inname, rsize)
Method you must define for your thumbnailer to do anything
make_working_dir(self)
Create the temporary directory and change into it.
post_process_image(self, img, w, h)
Perform some post-processing on the image.
img - gdk-pixbuf of the image
w - width
h - height
Return: modified image
The default implementation just returns the image unchanged.
process_image(self, img, rsize)
Take the raw image and scale it to the correct size.
Returns the result of scaling img and passing it to
post_process_image()
remove_working_dir(self)
Remove our temporary directory, after changing back to the
previous one
report_exception(self)
Report an exception if debug enabled, otherwise ignore it
run(self, inname, outname=None, rsize=96)
Generate the thumbnail from the file
inname - source file
outname - path to store thumbnail image, or None for default location
rsize - maximum size of thumbnail (in either axis)
store_image(self, img, inname, outname, ow, oh)
Store the thumbnail image it the correct location, adding
the extra data required by the thumbnail spec.

 
Functions
       
generate(path)
Generate the thumbnail for a file.  If a generator for the type of
path is not available then None is returned, otherwise an integer
which is the exit code of the generation process (0 for success).
get_image(fname)
Given a file name return a GdkPixbuf of the thumbnail for that file.
If no thumbnail image exists return None.
get_method(path=None, mtype=None)
Look up the program for generating a thumbnail.  Specify either
a path to a file or a MIME type.
 
This returns False if there is no defined method to generate the thumbnail,
True if the thumbnail would be generated internally using GdkPixbuf, or
a string giving the full path to a program called to generate the
thumbnail.
get_path(fname)
Given a file name return the full path of an existing thumbnail
image.  If no thumbnail image exists, return None
get_path_save(fname, ttype='normal')
Given a file name return the full path of the location to store the
thumbnail image.
 
ttype should be 'normal' or 'large' to specify the size, or 'fail' when
thumbnail creation has failed
md5hash(s)