mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge branch 'icns-support' into icns+jp2k
This commit is contained in:
commit
cbe7e93bdd
BIN
Images/pillow.icns
Normal file
BIN
Images/pillow.icns
Normal file
Binary file not shown.
|
@ -74,7 +74,7 @@ def read_32(fobj, start_length, size):
|
|||
"Error reading channel [%r left]" % bytesleft
|
||||
)
|
||||
band = Image.frombuffer(
|
||||
"L", size, b"".join(data), "raw", "L", 0, 1
|
||||
"L", pixel_size, b"".join(data), "raw", "L", 0, 1
|
||||
)
|
||||
im.im.putband(band.im, band_ix)
|
||||
return {"RGB": im}
|
||||
|
@ -166,7 +166,7 @@ class IcnsFile:
|
|||
self.dct = dct = {}
|
||||
self.fobj = fobj
|
||||
sig, filesize = nextheader(fobj)
|
||||
if sig != 'icns':
|
||||
if sig != b'icns':
|
||||
raise SyntaxError('not an icns file')
|
||||
i = HEADERSIZE
|
||||
while i < filesize:
|
||||
|
|
BIN
Tests/images/pillow2.icns
Normal file
BIN
Tests/images/pillow2.icns
Normal file
Binary file not shown.
42
Tests/test_file_icns.py
Normal file
42
Tests/test_file_icns.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from tester import *
|
||||
|
||||
from PIL import Image
|
||||
|
||||
# sample icon file
|
||||
file = "Images/pillow.icns"
|
||||
data = open(file, "rb").read()
|
||||
|
||||
def test_sanity():
|
||||
# Loading this icon by default should result in the largest size
|
||||
# (512x512@2x) being loaded
|
||||
im = Image.open(file)
|
||||
im.load()
|
||||
assert_equal(im.mode, "RGBA")
|
||||
assert_equal(im.size, (1024, 1024))
|
||||
assert_equal(im.format, "ICNS")
|
||||
|
||||
def test_sizes():
|
||||
# Check that we can load all of the sizes, and that the final pixel
|
||||
# dimensions are as expected
|
||||
im = Image.open(file)
|
||||
for w,h,r in im.info['sizes']:
|
||||
wr = w * r
|
||||
hr = h * r
|
||||
im2 = Image.open(file)
|
||||
im2.size = (w, h, r)
|
||||
im2.load()
|
||||
assert_equal(im2.mode, 'RGBA')
|
||||
assert_equal(im2.size, (wr, hr))
|
||||
|
||||
def test_older_icon():
|
||||
# This icon was made with Icon Composer rather than iconutil; it still
|
||||
# uses PNG rather than JP2, however (since it was made on 10.9).
|
||||
im = Image.open('Tests/images/pillow2.icns')
|
||||
for w,h,r in im.info['sizes']:
|
||||
wr = w * r
|
||||
hr = h * r
|
||||
im2 = Image.open('Tests/images/pillow2.icns')
|
||||
im2.size = (w, h, r)
|
||||
im2.load()
|
||||
assert_equal(im2.mode, 'RGBA')
|
||||
assert_equal(im2.size, (wr, hr))
|
Loading…
Reference in New Issue
Block a user