« [Fonts]フォントデータコピー(Kit) | トップページ | [exiftool]JSONデータをPLISTに変換する »

[FONT]文字イメージ作成(途中)

Python3のアップデートと必要ならライブラリのインストール用

try
do shell script "/usr/bin/xcode-select --install"
end try
do shell script "chmod 777 $HOME/Library/Caches/pip"
do shell script "chmod 777 $HOME/Library/Python/3.8/lib/python/site-packages"
##
do shell script "/usr/bin/python3 -m pip install --user numpy"
do shell script "/usr/bin/python3 -m pip install --user pip"
do shell script "/usr/bin/python3 -m pip install --user Pillow"
do shell script "/usr/bin/python3 -m pip install --user image"
do shell script "/usr/bin/python3 -m pip install --user django"
do shell script "/usr/bin/python3 -m pip install --user fonttools"
do shell script "/usr/bin/python3 -m pip install --upgrade --user numpy"
do shell script "/usr/bin/python3 -m pip install --upgrade --user pip"
do shell script "/usr/bin/python3 -m pip install --upgrade --user Pillow"
do shell script "/usr/bin/python3 -m pip install --upgrade --user image"
do shell script "/usr/bin/python3 -m pip install --upgrade --user django"
do shell script "/usr/bin/python3 -m pip install --upgrade --user fonttools"

#!/usr/bin/env python3

# coding: utf-8

from PIL import Image, ImageDraw, ImageFont

from datetime import datetime

import os

import sys

import urllib.parse


theGerData = sys.argv

 

theFileName = os.path.basename(theGerData[1])

thePsFileName = os.path.basename(theGerData[2])

thePsFileNameJP = os.path.basename(theGerData[3])

theExtension = os.path.splitext(theGerData[1])

print(theExtension)

objImg = Image.new('RGB', (960, 480), color = (0, 114, 188))


objFont = ImageFont.truetype(theGerData[1], size=36,encoding='unic')


d = ImageDraw.Draw(objImg)

d.text((10,10), "ABCDEFGHIJKLMNOPQRSTUVWXYZ*#$%&", font=objFont,fill=(0,0,0))

d.text((10,50), "abcdefghijklmnopqrstuvwxyz01234567890", font=objFont,fill=(255,255,255))

#d.text((10,100), "", font=objFont,fill=(0,0,0))

d.text((30,100), theFileName, font=objFont,fill=(0,0,0))

d.text((30,150), thePsFileName, font=objFont,fill=(255,255,255))

d.text((30,200), thePsFileNameJP, font=objFont,fill=(0,0,0))

d.text((10,260), "あいうえおやゃゆゅよょわをんざじずせぞ", font=objFont,fill=(255,255,255))

d.text((10,300), "アイウエオガギグゲゴヤャユュヨョワヲン", font=objFont,fill=(0,0,0))

d.text((10,340), "※『』@【】「」#$%&", font=objFont,fill=(255,255,255))

d.text((10,380), "ABCDefgHIJK12340", font=objFont,fill=(0,0,0))

d.text((10,420), "祇辻飴葛蛸鯖鰯噌庖箸", font=objFont,fill=(255,255,255))





theNow = datetime.now()

##theNowDateAndTiime = theNow.strftime("%Y%m%d_%H%M%S")

theNowDateAndTiime = "FontsImages"

access_rights = 0o755

theTmpPath = "/Users/Shared/Pictures/"


theSavePath = os.path.join(theTmpPath, theNowDateAndTiime)


##os.mkdir(theSavePath, access_rights)

theFileNamePng = (theFileName + '.png')

theSaveFilePath = os.path.join(theSavePath,theFileNamePng)


objImg.save(theSaveFilePath)


|

« [Fonts]フォントデータコピー(Kit) | トップページ | [exiftool]JSONデータをPLISTに変換する »

AppleScript Fonts」カテゴリの記事