Monday, December 28, 2009

PyWin32とImageMagickで付箋紙を描画する

PyWin32とImageMagickで付箋紙を描画するには、以下のコードを実行します。


# coding=UTF-8
import win32com.client

im = win32com.client.Dispatch("ImageMagickObject.MagickImage.1")
im.convert("-size", "200x200", "gradient:#f4f070-#e0cc4c",
"-font", "Comic-Sans-MS-Bold", "-pointsize", "20", "-background",
"none", "-gravity", "center", "-annotate", "0",
"To Do\n4:30 Meeting.", "-gravity", "northwest",
"-alpha", "activate", "-channel", "rgba", "-background", "none",
"-splice", "20x0", "-virtual-pixel", "background", "-fx",
"p{i+j^2*0.0005,j}", "-shear", "0x3", "(", "-size", "200x200",
"xc:black", "-background", "none", "-splice", "20x0",
"-shear", "0x3", "-shadow", "60x3+3+5", ")", "(", "-size",
"200x200", "xc:white", ")", "-swap", "0,2", "-mosaic",
"sample1407a.png")


出力画像(sample1407a.png)
PyWin32とImageMagickで描画した付箋紙

動作環境
Python3.1.1, Python for Windows Extensions (Build 214), ImageMagick6.5.5

No comments: