View Single Post
Old 01-29-2010, 07:10 AM   #5
Iņigo
Guru
Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.Iņigo did not drink the Kool Aid.
 
Posts: 730
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, iRex DR800S. K4NT. Kobo Aura, Aura One, Libra 2.
If I've understood correctly, it should not be too hard for .pdf files.

Locate the images files in filesystem used in boot and shutdown processes.
Change the shutdown process with a script that 1. change those images with a
screenshot of the page currently reading, and 2. do a shutdown

Page number could be extracted from the manifest.

This is a sample python code that creates an image of a pdf file page.
It shouldn't be difficult to translate to C or lua.

Code:
import gtk
import gtk.gdk
import poppler

def build_cover_pdf_poppler(f):
    """poppler method. Needs X"""
    dst = mkstemp()[1]
    try:
        doc = poppler.document_new_from_file('file://' + f, None)
    except:
        os.unlink(dst)
        return
    pag = doc.get_page(0)
    w, h = map(int, pag.get_size())
    pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, w, h)
    pag.render_to_pixbuf(0, 0, w, h, 1, 0, pb)
    pb_scaled = pb.scale_simple(TN_W, TN_H, gtk.gdk.INTERP_BILINEAR)
    pb_scaled.save(dst, 'jpeg', {'quality': TN_QUALITY})
Iņigo
Iņigo is offline   Reply With Quote