To make a repeating image tile from a photo in Python, place a crop in a 2 × 2 grid and flip the right column and bottom row. Matching edges meet when the tile repeats. In the cover example, the straight repeat on the left has abrupt joins. The mirror repeat on the right joins matching colors, although you can still see the symmetry.
Choose a crop with texture
Download the Coffee Beans with Copy Space WebP and name it coffee.webp. It is an AI-generated image available under the Stock Tour Asset License. The example takes a 500 × 500 crop where the beans meet the paper and resizes it to 240 × 240. Leave room between the main shapes if you want the repeat to look less dense.
Make a four-part mirror tile
Install Pillow with python3 -m pip install Pillow in your Python environment. Save this as make-tile.py beside the WebP and run python3 make-tile.py. For another source image, change the crop coordinates to a box inside that file. The example crop coordinates are left, top, right, and bottom in pixels.
from PIL import Image, ImageOps
with Image.open("coffee.webp") as source:
crop = source.convert("RGB").crop((790, 40, 1290, 540))
patch = crop.resize((240, 240), Image.Resampling.LANCZOS)
width, height = patch.size
mirror = ImageOps.mirror(patch)
tile = Image.new("RGB", (2 * width, 2 * height))
tile.paste(patch, (0, 0))
tile.paste(mirror, (width, 0))
tile.paste(ImageOps.flip(patch), (0, height))
tile.paste(ImageOps.flip(mirror), (width, height))
tile.save("coffee-tile.png")
Pillow’s mirror and flip operations reverse the image horizontally and vertically. The 480 × 480 output combines the original, a horizontal flip, a vertical flip, and a flip in both directions. That keeps the left and right edges identical and the top and bottom edges identical.
Repeat the tile and inspect the joins
With the same coffee crop, all 240 left-to-right edge pixel pairs and all 240 top-to-bottom pairs differed in the straight repeat. In the exported PNG, every pair on both axes matched. The visual trade-off is easy to see on the right: the beans form symmetric clusters where they meet. If that shape distracts from a heading, shrink the repeat or choose a single background with room for text.
Put the PNG beside your stylesheet and apply this CSS to your background section. background-size sets the tile’s display width, and background-repeat repeats it across both axes. Keep important copy in a solid panel over the pattern.
.coffee-background {
background-color: #efe2cf;
background-image: url("coffee-tile.png");
background-size: 360px auto;
background-repeat: repeat;
}



