Last active
August 29, 2015 14:27
-
-
Save utgwkk/76a0af5503368fe4f570 to your computer and use it in GitHub Desktop.
画像ファイルを名刺印刷用の形式にするやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
cols, rows = 2, 4 | |
linewidth = 10 | |
img = Image.open("input.png") | |
width, height = img.size | |
size = width*cols+linewidth, height*rows+(rows-1)*linewidth | |
output = Image.new("RGB", size, (0, 0, 0)) | |
for y in range(rows): | |
h = (height+linewidth)*y | |
for i in range(cols): | |
output.paste(img, ((width+linewidth)*i, h)) | |
output.save("output.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment