ensure color mode compatibility when making image thumbnails
authorcfdv <caldavis@gmail.com>
Sun, 12 Jun 2011 22:35:07 +0000 (17:35 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 12 Jun 2011 22:35:07 +0000 (17:35 -0500)
mediagoblin/process_media/__init__.py

index c71c5dda6ef19b2fe53f83914ed7f9bacc9af3ff..f0a6e511124904cf7c45ea52f897128317b8f70a 100644 (file)
@@ -41,6 +41,9 @@ def process_media_initial(media_id):
     with queued_file:
         thumb = Image.open(queued_file)
         thumb.thumbnail(THUMB_SIZE, Image.ANTIALIAS)
+        # ensure color mode is compatible with jpg
+        if thumb.mode != "RGB":
+            thumb = thumb.convert("RGB")
 
         thumb_filepath = mgg.public_store.get_unique_filepath(
             ['media_entries',