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
2022-08-27 22:02:26 +08:00

22 lines
497 B
Python

from typing import List
from PIL import Image as PImage
from core.elements import Image
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