Commits

Fredrik Lundh committed cd40335

Disable WebP draft method.

  • Participants
  • Parent commits d007573

Comments (0)

Files changed (2)

PIL/WebPImagePlugin.py

         if len(self.tile) != 1:
             return
         d, e, o, a = self.tile[0]
-        if a[0] == "RGB" and mode in ["YCbCr"]:
-            self.mode = mode
-            a = (self.mode,)
+        # FIXME: enable YCbCr support in decoder
+        # if a[0] == "RGB" and mode in ["YCbCr"]:
+        #     self.mode = mode
+        #     a = (self.mode,)
         self.tile = [(d, e, o, a)]
-        return self
 
 
 def _save(im, fp, filename):

Tests/test_file_webp.py

     assert_equal(im1.mode, im2.mode)
     assert_equal(im1.size, im2.size)
 
-# def test_draft():
-#     # test draft mode
-#     im = Image.open("Images/lena.webp")
-#     px = im.getpixel((0, 0))
-#     im = Image.open("Images/lena.webp")
-#     im.draft("YCbCr", im.size)
+def test_draft():
+    # test draft mode
+    im = Image.open("Images/lena.webp")
+    px = im.getpixel((0, 0))
+    im = Image.open("Images/lena.webp")
+    im.draft("YCbCr", (256, 256))
+    assert_equal(im.mode, "RGB")  # ignored
+    assert_equal(im.size, (128, 128))
+    im.load()
+    assert_equal(im.mode, "RGB")
+    assert_equal(im.size, (128, 128))
+
 #     assert_equal(im.mode, "YCbCr")
 #     assert_equal(im.size, (128, 128))
 #     im.load()
 #     assert_equal(im.mode, "YCbCr")
 #     assert_equal(im.size, (128, 128))
-#     # make sure the codec doesn't read RGB
+#     # make sure the codec doesn't read as RGB
 #     assert_false(px == im.getpixel((0, 0)))
 
 def test_quality():