Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/core/utils/image.py

23 lines
497 B
Python
Raw Normal View History

2022-08-27 14:02:26 +00:00
from typing import List
from PIL import Image as PImage
2023-02-05 14:33:33 +00:00
from core.builtins import Image
2022-08-27 14:02:26 +00:00
async def image_split(i: Image) -> List[Image]:
i = PImage.open(await i.get())
iw, ih = i.size
if ih <= 1500:
return [Image(i)]
_h = 0
i_list = []
for x in range((ih // 1500) + 1):
if _h + 1500 > ih:
crop_h = ih
else:
crop_h = _h + 1500
i_list.append(Image(i.crop((0, _h, iw, crop_h))))
_h = crop_h
return i_list