[FIX] resize_image: auto convert BMP images to PNG
authorChristophe Simonis <chs@openerp.com>
Tue, 1 Apr 2014 15:44:17 +0000 (17:44 +0200)
committerChristophe Simonis <chs@openerp.com>
Tue, 1 Apr 2014 15:44:17 +0000 (17:44 +0200)
bzr revid: chs@openerp.com-20140401154417-c8buuqybdsihn3om

openerp/tools/image.py

index 08c2fd9..93458fb 100644 (file)
@@ -70,7 +70,11 @@ def image_resize_image(base64_source, size=(1024, 1024), encoding='base64', file
     image_stream = StringIO.StringIO(base64_source.decode(encoding))
     image = Image.open(image_stream)
     # store filetype here, as Image.new below will lose image.format
-    filetype = filetype or image.format
+    filetype = (filetype or image.format).upper()
+
+    filetype = {
+        'BMP': 'PNG',
+    }.get(filetype, filetype)
 
     asked_width, asked_height = size
     if asked_width is None: