Update of /cvsroot/freevo/freevo/src/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25412/src/util

Modified Files:
        fileops.py 
Log Message:
expect errors when loading image

Index: fileops.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/util/fileops.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** fileops.py  9 Jun 2004 20:09:10 -0000       1.19
--- fileops.py  13 Jun 2004 18:47:46 -0000      1.20
***************
*** 11,14 ****
--- 11,17 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.20  2004/06/13 18:47:46  dischi
+ # expect errors when loading image
+ #
  # Revision 1.19  2004/06/09 20:09:10  dischi
  # cleanup
***************
*** 470,495 ****
  
  
! def cache_image(filename, thumbnail=None, use_exif=False):
      """
!     cache image for faster access, return cached image
      """
      thumb = vfs.getoverlay(filename + '.raw')
-     try:
-         if os.stat(thumb)[stat.ST_MTIME] > os.stat(filename)[stat.ST_MTIME]:
-             data = read_thumbnail(thumb)
-             if data:
-                 return data
-     except OSError:
-         pass
- 
      image = None
      if thumbnail:
          try:
              image = Image.open(cStringIO.StringIO(thumbnail))
!         except:
!             pass
  
      if not image:
!         if use_exif:
              f=open(filename, 'rb')
              tags=exif.process_file(f)
--- 473,493 ----
  
  
! def create_thumbnail(filename, thumbnail=None):
      """
!     cache image for faster access
      """
      thumb = vfs.getoverlay(filename + '.raw')
      image = None
+ 
      if thumbnail:
          try:
              image = Image.open(cStringIO.StringIO(thumbnail))
!         except Exception, e:
!             print 'Invalid thumbnail for %s' % filename
!             if config.DEBUG:
!                 print e
  
      if not image:
!         if __freevo_app__ == 'main':
              f=open(filename, 'rb')
              tags=exif.process_file(f)
***************
*** 497,501 ****
              
              if tags.has_key('JPEGThumbnail'):
!                 image = Image.open(cStringIO.StringIO(tags['JPEGThumbnail']))
  
          if not image or image.size[0] < 100 or image.size[1] < 100:
--- 495,504 ----
              
              if tags.has_key('JPEGThumbnail'):
!                 try:
!                     image = Image.open(cStringIO.StringIO(tags['JPEGThumbnail']))
!                 except Exception, e:
!                     print 'Error loading thumbnail %s' % filename
!                     if config.DEBUG:
!                         print e
  
          if not image or image.size[0] < 100 or image.size[1] < 100:
***************
*** 520,523 ****
      f.write(data[0])
      f.close()
- 
      return data
--- 523,542 ----
      f.write(data[0])
      f.close()
      return data
+ 
+ 
+ def cache_image(filename, thumbnail=None, use_exif=False):
+     """
+     cache image for faster access, return cached image
+     """
+     thumb = vfs.getoverlay(filename + '.raw')
+     try:
+         if os.stat(thumb)[stat.ST_MTIME] > os.stat(filename)[stat.ST_MTIME]:
+             data = read_thumbnail(thumb)
+             if data:
+                 return data
+     except OSError:
+         pass
+ 
+     return create_thumbnail(filename, thumbnail)
+ 



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to