Skip to content

Commit cefcb22

Browse files
yuanyan3060yuanyan
andauthored
fix type hint Image to Image.Image (K0lb3#108)
Co-authored-by: yuanyan <[email protected]>
1 parent fa88c40 commit cefcb22

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

UnityPy/export/SpriteHelper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..streams import EndianBinaryReader
88

99

10-
def get_image(sprite, texture, alpha_texture) -> Image:
10+
def get_image(sprite, texture, alpha_texture) -> Image.Image:
1111
if (
1212
alpha_texture
1313
and getattr(alpha_texture, "type", ClassIDType.UnknownType)
@@ -29,7 +29,7 @@ def get_image(sprite, texture, alpha_texture) -> Image:
2929
return sprite.assets_file._cache[cache_id]
3030

3131

32-
def get_image_from_sprite(m_Sprite) -> Image:
32+
def get_image_from_sprite(m_Sprite) -> Image.Image:
3333
atlas = None
3434
if m_Sprite.m_SpriteAtlas:
3535
atlas = m_Sprite.m_SpriteAtlas.read()

UnityPy/export/Texture2DConverter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
TF = TextureFormat
1010

1111

12-
def image_to_texture2d(img: Image, target_texture_format: TF, flip: bool = True):
12+
def image_to_texture2d(img: Image.Image, target_texture_format: TF, flip: bool = True):
1313
if flip:
1414
img = img.transpose(Image.FLIP_TOP_BOTTOM)
1515

@@ -76,7 +76,7 @@ def image_to_texture2d(img: Image, target_texture_format: TF, flip: bool = True)
7676
return enc_img, tex_format
7777

7878

79-
def get_image_from_texture2d(texture_2d, flip=True) -> Image:
79+
def get_image_from_texture2d(texture_2d, flip=True) -> Image.Image:
8080
"""converts the given texture into PIL.Image
8181
8282
:param texture_2d: texture to be converterd
@@ -153,7 +153,7 @@ def pillow(
153153
codec: str,
154154
args,
155155
swap: tuple = None,
156-
) -> Image:
156+
) -> Image.Image:
157157
img = (
158158
Image.frombytes(mode, (width, height), image_data, codec, args)
159159
if width
@@ -165,7 +165,7 @@ def pillow(
165165
return img
166166

167167

168-
def atc(image_data: bytes, width: int, height: int, alpha: bool) -> Image:
168+
def atc(image_data: bytes, width: int, height: int, alpha: bool) -> Image.Image:
169169
if alpha:
170170
image_data = texture2ddecoder.decode_atc_rgba8(image_data, width, height)
171171
else:
@@ -174,7 +174,7 @@ def atc(image_data: bytes, width: int, height: int, alpha: bool) -> Image:
174174
return Image.frombytes("RGBA", (width, height), image_data, "raw", "BGRA")
175175

176176

177-
def astc(image_data: bytes, width: int, height: int, block_size: tuple) -> Image:
177+
def astc(image_data: bytes, width: int, height: int, block_size: tuple) -> Image.Image:
178178
image_data = texture2ddecoder.decode_astc(image_data, width, height, *block_size)
179179
return Image.frombytes("RGBA", (width, height), image_data, "raw", "BGRA")
180180

@@ -219,7 +219,7 @@ def half(
219219
codec: str,
220220
args,
221221
swap: tuple = None,
222-
) -> Image:
222+
) -> Image.Image:
223223
# convert half-float to int8
224224
stream = BytesIO(image_data)
225225
image_data = bytes(

0 commit comments

Comments
 (0)