INNER CODE UNIT · Python
_mosaic_pixel
zhulinyv/Semi-Auto-NovelAI-to-Pixiv · src/batch_mosaic.py:48
def _mosaic_pixel(image, region, block_size):
left, upper, right, lower = region
cropped_image = image.crop(region)
small = cropped_image.resize(
(int((right - left) / block_size), int((lower - upper) / block_size)), resample=Image.Resampling.NEAREST
)
mosaic_image = small.resize(cropped_image.size, Image.Resampling.NEAREST)
image.paste(mosaic_image, region)
return image
def mosaic_pixel(img_path):
img_path = str(img_path)
box_list = detector(img_path)