From aee5d22a2082350ee36e5cd425d94b20990b9e07 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 15 Feb 2020 14:17:38 +1100 Subject: [PATCH] Added convert_mode param when saving --- Tests/images/pil123rgba_red.jpg | Bin 0 -> 4666 bytes Tests/test_file_gif.py | 11 ++++++++ Tests/test_file_jpeg.py | 16 +++++++++-- Tests/test_file_png.py | 8 ++++++ Tests/test_file_webp.py | 8 ++++++ Tests/test_image.py | 17 +++++++++++- src/PIL/GifImagePlugin.py | 7 +++++ src/PIL/Image.py | 46 ++++++++++++++++++++++++++++---- src/PIL/JpegImagePlugin.py | 11 ++++++++ src/PIL/PngImagePlugin.py | 6 +++++ src/PIL/WebPImagePlugin.py | 13 +++++++++ 11 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 Tests/images/pil123rgba_red.jpg diff --git a/Tests/images/pil123rgba_red.jpg b/Tests/images/pil123rgba_red.jpg new file mode 100644 index 0000000000000000000000000000000000000000..073a654366dd60e2420e99ad61ec88e17cf76c49 GIT binary patch literal 4666 zcmbW4XE+?(w#R4G7(JQ6=ux7JUV;e8s4t^r)Fg;b^dNea5Q7n25JVe{61_)Dv?K&$ zh?>#c5WNLQ-g9nw?)`GlUHkd(FMB=vS-)M^x}3QD382$b(^LZhfdByTssS#i0QUjc z$jHdaNUxETlT%P!15tsgsVFI_px1BEg4vik*x8s_Svh$``8c_Rxmj8HWd(%A#HFO9 zIQZn1gcJ>aAPF~NweSBZ|`G-fmii~<4jZ92RPDxEmf18n)Ur<_Ue_&)3JBAyd_%Vr}UszmPURhmR-`U;UKR7%(J~{ov1q2ZP z6YHw~C)oesqQBxIA|W9rA^*b#B=WryF+Bwg8D*EJB9yhooLa%{U6W&*KQgBNe z{DM6790oD)Na1;R{-FI$_J0El`+t%BC)j^+O#-NhfmfSHOb<{7%&+DlPm+%4@{s(1 ze~O}`KUW4MSp8V3s}E;1GW~j|EkSo|sJ*hmEX=rxie$Xr=l8Fw#)SCuy%vtwkTE#9 z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