Help us understand the problem. What is going on with this article?

OS Xのコマンドラインで文字列を画像化するメモ

More than 3 years have passed since last update.

参考URL

(というかほぼここの通り)
http://www.cnx-software.com/2011/09/22/how-to-convert-a-command-line-result-into-an-image-in-linux/

必要ツールをインストールする

(brewは省略)

brew install imagemagick
brew install ghostscript

スクリプトを作成する

cmd2png.sh
#!/bin/sh

# 色設定
bg="black"
fg="white"

# フォント設定
# font="/System/Library/Fonts/Menlo.ttc"
font="/System/Library/Fonts/ヒラギノ角ゴシック W3.ttc"
fontsize="10"

# 出力ファイル名
outfile="$1"

if [ "$1." == "." ]; then
outfile="text.png"
fi

# 変換
convert -background $bg -bordercolor $bg -fill $fg -font "$font" -pointsize $fontsize -border 25 label:@- $outfile

実行権限を忘れずに。
chmod +x cmd2png.sh

コマンドラインで試す

echo "Hello" | ./cmd2png.sh

もしくは任意の出力ファイル名で。
echo "Hello" | ./cmd2png.sh image.jpg

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away