~robinmills/phatch/geotag

« back to all changes in this revision

Viewing changes to phatch/lib/thumbnail.py

  • Committer: spe.stani.be at gmail
  • Date: 2010-03-21 21:11:49 UTC
  • mfrom: (1887.1.11 windows)
  • Revision ID: spe.stani.be@gmail.com-20100321211149-zax6mxrsje14820m
Stani 2010-03-21 put tempfiles between try ... finally

Show diffs side-by-side

added added

removed removed

Lines of Context:
249
249
            thumb, thumb_cache, size, pnginfo, **options):
250
250
        thumb_cache.thumbnail(FREEDESKTOP_SIZE[cache_size_label],
251
251
            Image.ANTIALIAS)
 
252
        thumb_filename = get_freedesktop_filename(filename, cache_size_label)
252
253
        temp = system.TempFile('.png')
253
 
        imtools.save(thumb_cache, temp.path, pnginfo=pnginfo, **options)
254
 
        thumb_filename = get_freedesktop_filename(filename, cache_size_label)
255
 
        temp.close(dest=thumb_filename)
 
254
        try:
 
255
            imtools.save(thumb_cache, temp.path, pnginfo=pnginfo, **options)
 
256
        finally:
 
257
            temp.close(dest=thumb_filename)
256
258
        os.chmod(thumb_filename, 0600)
257
259
        if cache_size_label == size_label:
258
260
            # make thumbnail as it is smaller than this thumb cache size