Pass filename instead of file object when calling PIL.Image.save()
author宋文武 <iyzsong@gmail.com>
Tue, 12 Jan 2016 01:48:00 +0000 (09:48 +0800)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 21 Jan 2016 20:27:57 +0000 (12:27 -0800)
mediagoblin/media_types/ascii/processing.py
mediagoblin/media_types/image/processing.py

index ed6600eee4522c588c16df5173693827d0729eb0..00d04e63e657beb7abb92d630b9cefa7c2fd637d 100644 (file)
@@ -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],
index 951a720d1d5c515234886634a339ed22f027e177..14091d6ec16a89a0dae3b4ecb97579fbf129d7d1 100644 (file)
@@ -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