Chandan Pitta wrote:
> Try this patch.

Patch worked fine now in svn rel-1 at r8917

I have these functions in util.fileops.py which is now updated from the
patch you have sent. They is called when "freevo cache" is run.

def cache_www_thumbnail_path(filename):
    '''returns the path to the thumbnail image for a given filename
    '''
    file_ext_index = filename.rindex(".")
    file_ext = filename[file_ext_index:].lower()
    if file_ext == ".gif":
        file_ext += ".jpg"
    imagepath = filename[:file_ext_index].replace("/", "_") + file_ext
    thumb_path = os.path.join(www_image_cachedir(), imagepath)
    return thumb_path

def cache_www_image(filename):
    '''creates a webserver thumbnail image and returns its size.
    '''
    thumb_path = www_cache_thumbnail_path(filename)
    image = imlib2.open(filename)
    thumb = image.scale_preserve_aspect(config.WWW_IMAGE_THUMBNAIL_SIZE)
    thumb.save(thumb_path)
    return thumb.size

What this means is that we're not quite finished yet :( sorry. Cache
needs to cache every image, size doesn't matter it's determined by the
timestamp between the original item and the cached item.

The functions is called like this:
        sinfo = os.stat(filename)
        thumb = util.cache_www_thumbnail_path(filename)
        try:
            if os.stat(thumb)[stat.ST_MTIME] > sinfo[stat.ST_MTIME]:
                files.remove(filename)
        except OSError:
            pass

All this means it that it makes this code simpler, you don't need to
worry about threshold sizes or aspect ratios, the helper functions in
util.fileops does this for you.

So the library.rpy only needs to check if the
cache_www_thumbnail_path(path) exist and if not call
cache_www_image(thumb_path).

This will be much cleaner and easier to maintain. When you get some time
could you do the changes.

Many thanks
Duncan


> On 1/2/07, Duncan Webb <[EMAIL PROTECTED]> wrote:
>> Chandan Pitta wrote:
>> > Sorry attached the wrong diff file. See this one
>>
>> I can't apply this patch, says that it has been previously detected.
>>
>> Will you try an svn update, I applied Wout's patch at 8912 and your
>> one-liner after.
>>
>> Thanks
>> Duncan



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to