How to cut image as icon in Blender?
Although I have solved this problem for a long time, I see better answers in other places, so I sent them out
The first is the imbuf library, but the documents are not very detailed and haven't been updated for a long time
https://developer.blender.org/T54272
And then this
How to merge external images together in script?
Then my method is that the PIL library cuts the pictures, saves them to Blender's cache directory, and loads them through this path  

from . PIL_library64 import Image
import sys

def cut_image(image,x,y):
    # x指横上切的刀数
    width, height = image.size
    item_width = int(width / x)
    item_height = int(width / y)
    box_list = []
    # (left, upper, right, lower)
    for i in range(0,y):
        for j in range(0,x):
            box = (j*item_width,i*item_height,(j+1)*item_width,(i+1)*item_height)
            box_list.append(box)
    image_list = [image.crop(box) for box in box_list]
    return image_list

# 保存
def save_images(image_list):
    from os.path import exists
    from os import makedirs
    import bpy
    temppath=bpy.app.tempdir
    print(temppath)
    if not exists(temppath+"mi2bl"): # 判断文件夹存在
        makedirs(temppath+"mi2bl") # 创建文件夹
    index = 1
    file_list=[]
    for image in image_list:
        image.save(temppath+"mi2bl\\"+str(index) + '.png', 'PNG')
        file_list.append(temppath+"mi2bl\\"+str(index) + '.png')
        index += 1
    return file_list

#主函数-分割图片，存储到blender的项目缓存文件夹中
def image_crop(file_path, x, y):
    image = Image.open(file_path)
    #image.show()
    image_list = cut_image(image,x,y)
    file_list=save_images(image_list)
    return file_list
```