Skip to content

Commit c48b569

Browse files
committed
support for mode="1"
1 parent 1e457b3 commit c48b569

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

pillow_heif/heif.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ def __add_frame_from_pillow(self, frame: Image.Image, ignore_primary: bool, **kw
585585
frame = frame.convert(mode=mode)
586586
elif frame.mode == "LA":
587587
frame = frame.convert(mode="RGBA")
588+
elif frame.mode == "1":
589+
frame = frame.convert(mode="L")
588590

589591
if original_orientation is not None and original_orientation != 1:
590592
frame = ImageOps.exif_transpose(frame)

tests/opener_encoder_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ def test_LA_color_mode():
143143
imagehash.compare_hashes([png_pillow, heic_pillow], hash_type="dhash", hash_size=8, max_difference=1)
144144

145145

146+
def test_1_color_mode():
147+
png_pillow = Image.open(Path("images/jpeg_gif_png/L_color_mode_image.png"))
148+
png_pillow = png_pillow.convert(mode="1")
149+
out_heic = BytesIO()
150+
png_pillow.save(out_heic, format="HEIF", quality=-1, save_all=True)
151+
heic_pillow = Image.open(out_heic)
152+
imagehash.compare_hashes([png_pillow, heic_pillow], hash_type="dhash", hash_size=8, max_difference=1)
153+
154+
146155
def test_append_images():
147156
heic_pillow = Image.open(Path("images/rgb8_512_512_1_0.heic"))
148157
heic_pillow2 = Image.open(Path("images/rgb8_150_128_2_1.heic"))

0 commit comments

Comments
 (0)