Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utgwkk/76a0af5503368fe4f570 to your computer and use it in GitHub Desktop.
Save utgwkk/76a0af5503368fe4f570 to your computer and use it in GitHub Desktop.
画像ファイルを名刺印刷用の形式にするやつ
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