Ticket #5386: 0001-Pass-filename-instead-of-file-object-when-calling-PI.patch

File 0001-Pass-filename-instead-of-file-object-when-calling-PI.patch, 1.9 KB (added by 宋文武, 9 years ago)
  • mediagoblin/media_types/ascii/processing.py

    From b359bd318296210c25bdb20b8dc26965c1cc9ac8 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
    Date: Tue, 12 Jan 2016 09:48:00 +0800
    Subject: [PATCH] Pass filename instead of file object when calling
     PIL.Image.save()
    
    ---
     mediagoblin/media_types/ascii/processing.py | 7 ++-----
     mediagoblin/media_types/image/processing.py | 3 +--
     2 files changed, 3 insertions(+), 7 deletions(-)
    
    diff --git a/mediagoblin/media_types/ascii/processing.py b/mediagoblin/media_types/ascii/processing.py
    index ed6600e..00d04e6 100644
    a b class CommonAsciiProcessor(MediaProcessor):  
    143143            thumb = converter._create_image(
    144144                orig_file.read())
    145145
    146             with open(tmp_thumb, 'w') as thumb_file:
    147                 thumb.thumbnail(
    148                     thumb_size,
    149                     Image.ANTIALIAS)
    150                 thumb.save(thumb_file)
     146            thumb.thumbnail(thumb_size, Image.ANTIALIAS)
     147            thumb.save(tmp_thumb);
    151148
    152149            thumb_info = {'font': font,
    153150                          'width': thumb_size[0],
  • mediagoblin/media_types/image/processing.py

    diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py
    index 951a720..14091d6 100644
    a b def resize_image(entry, resized, keyname, target_name, new_size,  
    7777
    7878    # Copy the new file to the conversion subdir, then remotely.
    7979    tmp_resized_filename = os.path.join(workdir, target_name)
    80     with open(tmp_resized_filename, 'wb') as resized_file:
    81         resized.save(resized_file, quality=quality)
     80    resized.save(tmp_resized_filename, quality=quality)
    8281    store_public(entry, keyname, tmp_resized_filename, target_name)
    8382
    8483    # store the thumb/medium info