From: 宋文武 Date: Tue, 12 Jan 2016 01:48:00 +0000 (+0800) Subject: Pass filename instead of file object when calling PIL.Image.save() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ea309bff97bb3f291d15c769775fd1b0b6cd25d3;p=mediagoblin.git Pass filename instead of file object when calling PIL.Image.save() --- diff --git a/mediagoblin/media_types/ascii/processing.py b/mediagoblin/media_types/ascii/processing.py index ed6600ee..00d04e63 100644 --- a/mediagoblin/media_types/ascii/processing.py +++ b/mediagoblin/media_types/ascii/processing.py @@ -143,11 +143,8 @@ class CommonAsciiProcessor(MediaProcessor): thumb = converter._create_image( orig_file.read()) - with open(tmp_thumb, 'w') as thumb_file: - thumb.thumbnail( - thumb_size, - Image.ANTIALIAS) - thumb.save(thumb_file) + thumb.thumbnail(thumb_size, Image.ANTIALIAS) + thumb.save(tmp_thumb); thumb_info = {'font': font, 'width': thumb_size[0], diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py index 951a720d..14091d6e 100644 --- a/mediagoblin/media_types/image/processing.py +++ b/mediagoblin/media_types/image/processing.py @@ -77,8 +77,7 @@ def resize_image(entry, resized, keyname, target_name, new_size, # Copy the new file to the conversion subdir, then remotely. tmp_resized_filename = os.path.join(workdir, target_name) - with open(tmp_resized_filename, 'wb') as resized_file: - resized.save(resized_file, quality=quality) + resized.save(tmp_resized_filename, quality=quality) store_public(entry, keyname, tmp_resized_filename, target_name) # store the thumb/medium info