Duncan Webb wrote:
> 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.

I should add, really great work.

It's a bit strange about gifs and uppercase extensions.

Do you by chance have giflib or gifunlib installed when imlib2 was
built? giflib replaced gifunlib when the gif patent expired. imlib2 has
some amd64 bugs until version 1.3.0.

The uppercase extensions is a non-linux case and I'm not too surprised
that it doesn't work.

File extensions is not the best way to determine a file type, but this
is how cache works. The better way is using kaa.metadata.parse() and
here is some output from mminfo, which just prints the output from
kaa.metadata.parse()'s __str__ function.

/freevo/images/2005-11-18/logo_david.png
|       type: PNG image
|      media: MEDIA_IMAGE
|       mime: image/png
|      width: 127
|     height: 141

/freevo/images/2005-11-18/DSC02454.JPG
|       type: jpeg image
|       date: 2005:11:18 17:47:52
|      media: MEDIA_IMAGE
|       mime: image/jpeg
|      width: 2304
|     height: 3072
|   hardware: DSC-P150

Sorry for the extra work, but it is really very nearly finished. :)

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