Author: duncan
Date: Wed Jan 3 04:29:01 2007
New Revision: 8918
Modified:
branches/rel-1/freevo/src/helpers/cache.py
branches/rel-1/freevo/src/util/fileops.py
Log:
Changed cache and helper functions to be in-line with library.rpy
Added and renamed function to help.
Modified: branches/rel-1/freevo/src/helpers/cache.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/cache.py (original)
+++ branches/rel-1/freevo/src/helpers/cache.py Wed Jan 3 04:29:01 2007
@@ -224,8 +224,7 @@
files = util.misc.unique(files)
for filename in copy.copy(files):
sinfo = os.stat(filename)
- filepath = filename.replace("/", "_").replace(".", "_") + ".jpg"
- thumb = os.path.join(cache_dir, filepath)
+ thumb = util.cache_www_thumbnail_path(filename)
try:
if os.stat(thumb)[stat.ST_MTIME] > sinfo[stat.ST_MTIME]:
files.remove(filename)
Modified: branches/rel-1/freevo/src/util/fileops.py
==============================================================================
--- branches/rel-1/freevo/src/util/fileops.py (original)
+++ branches/rel-1/freevo/src/util/fileops.py Wed Jan 3 04:29:01 2007
@@ -561,15 +561,22 @@
return cache_dir
-def cache_www_image(filename):
- '''cache an image for webservers
- when the image is larger than WWW_IMAGE_THRESHOLD_SIZE then the image size
- is returned. Otherwise the thumbnail size is returned
+def cache_www_thumbnail_path(filename):
+ '''returns the path to the thumbnail image for a given filename
'''
- threshold_size = config.WWW_IMAGE_THRESHOLD_SIZE
- thumbnail_size = config.WWW_IMAGE_THUMBNAIL_SIZE
- imagepath = filename.replace("/", "_").replace(".", "_") + ".jpg"
+ 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 = cache_www_thumbnail_path(filename)
image = imlib2.open(filename)
thumb = image.scale_preserve_aspect(config.WWW_IMAGE_THUMBNAIL_SIZE)
thumb.save(thumb_path)
-------------------------------------------------------------------------
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-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog