mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
do not accept int in PIL._binary.i8
This commit is contained in:
parent
6a33d6d170
commit
3396ce102d
|
@ -20,26 +20,29 @@ import os
|
|||
import tempfile
|
||||
|
||||
from . import Image, ImageFile
|
||||
from ._binary import i8, o8
|
||||
from ._binary import i16be as i16
|
||||
from ._binary import i32be as i32
|
||||
|
||||
COMPRESSION = {1: "raw", 5: "jpeg"}
|
||||
|
||||
PAD = o8(0) * 4
|
||||
PAD = b"\0\0\0\0"
|
||||
|
||||
|
||||
#
|
||||
# Helpers
|
||||
|
||||
|
||||
def _i8(c: int | bytes) -> int:
|
||||
return c if isinstance(c, int) else c[0]
|
||||
|
||||
|
||||
def i(c):
|
||||
return i32((PAD + c)[-4:])
|
||||
|
||||
|
||||
def dump(c):
|
||||
for i in c:
|
||||
print("%02x" % i8(i), end=" ")
|
||||
print("%02x" % _i8(i), end=" ")
|
||||
print()
|
||||
|
||||
|
||||
|
@ -103,10 +106,10 @@ class IptcImageFile(ImageFile.ImageFile):
|
|||
self.info[tag] = tagdata
|
||||
|
||||
# mode
|
||||
layers = i8(self.info[(3, 60)][0])
|
||||
component = i8(self.info[(3, 60)][1])
|
||||
layers = self.info[(3, 60)][0]
|
||||
component = self.info[(3, 60)][1]
|
||||
if (3, 65) in self.info:
|
||||
id = i8(self.info[(3, 65)][0]) - 1
|
||||
id = self.info[(3, 65)][0] - 1
|
||||
else:
|
||||
id = 0
|
||||
if layers == 1 and not component:
|
||||
|
|
|
@ -18,8 +18,8 @@ from __future__ import annotations
|
|||
from struct import pack, unpack_from
|
||||
|
||||
|
||||
def i8(c: int | bytes) -> int:
|
||||
return c if c.__class__ is int else c[0] # type: ignore[index, return-value]
|
||||
def i8(c: bytes) -> int:
|
||||
return c[0]
|
||||
|
||||
|
||||
def o8(i: int) -> bytes:
|
||||
|
|
Loading…
Reference in New Issue
Block a user