Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
import numpy as np
from PIL import Image, ImageOps, ImageChopsimg = Image.open("../../home/media/poker/4h.png")
img
ImageChops.offset¶
Shift to the left with 10 pixels.
ImageChops.offset(img, -10, 0)
Image.crop and ImageOps.pad¶
img.crop((10, 0, 37, 54))
img_crop = img.crop((10, 0, 37, 54))
ImageOps.pad(img_crop, img.size, color="white", centering=(0, 0))
img_crop = img.crop((10, 0, 37, 54))
ImageOps.pad(img_crop, img.size, color="black", centering=(0, 0))
Image.crop and ImageOps.fit¶
img_crop = img.crop((10, 0, 37, 54))
ImageOps.pad(img_crop, img.size, method=0, centering=(0, 0))