How can I use Python to layout a page of images efficiently? or What’s the best way to use Python to

16 Replies, 1165 Views

PIL/Pillow is solid, but for a *simpler* way to use python to layout a page of images, try `opencv` + `numpy`. Stitch images together like a puzzle.

If sizes vary, resize 'em first:
```python
import cv2
imgs = [cv2.resize(img, (200,200)) for img in imgs] # force same size
grid = np.vstack([np.hstack(imgs[:2]), np.hstack(imgs[2:])])
cv2.imshow('grid', grid)
```
Kinda hacky, but works in a pinch!

Messages In This Thread



Users browsing this thread: 1 Guest(s)