Skip to content

Instantly share code, notes, and snippets.

@takehiko
Created September 16, 2017 09:23
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 takehiko/7c3c7e1fbcda605c4298027c61b8d7f5 to your computer and use it in GitHub Desktop.
Save takehiko/7c3c7e1fbcda605c4298027c61b8d7f5 to your computer and use it in GitHub Desktop.
『小学校学習指導要領解説算数編』のアレイ図比較画像作成
#!/bin/bash
# arrays-2008-2017.bash : 『小学校学習指導要領解説算数編』のアレイ図比較画像作成
# by takehikom
# 使用するコマンド:wget, convert (ImageMagick), unzip
# コマンド中の日本語文字にも注意
# 『小学校学習指導要領解説算数編』(平成20年)からアレイ図を取り出す
if [ ! -f 2008a.pdf ]
then
wget -O 2008a.pdf http://www.mext.go.jp/component/a_menu/education/micro_detail/__icsFiles/afieldfile/2009/06/16/1234931_004_2.pdf
fi
convert -density 400 2008a.pdf\[67\] -quality 100 2008b.jpg
convert -crop 1008x343+769+1926 -resize '400x136!' 2008b.jpg 2008c.png
# ただし上記PDFではフォントが埋め込まれていないためか画像が汚い
# Adobe Acrobat Readerで表示したものを2008c+.pngとして作っていれば
# それを使用する
if [ -f 2008c+.png ]
then
pic2008=2008c+.png
else
pic2008=2008c.png
fi
# 『小学校学習指導要領解説算数編』(平成29年)からアレイ図を取り出す
if [ ! -f 2017a.pdf ]
then
wget -O 2017a.pdf http://www.mext.go.jp/component/a_menu/education/micro_detail/__icsFiles/afieldfile/2017/07/25/1387017_4_2.pdf
fi
convert -density 400 2017a.pdf\[79\] -quality 100 2017b.jpg
convert -crop 786x212+1116+2270 -resize '393x106!' 2017b.jpg 2017c.png
# IPAexゴシックを取り出す
if [ ! -f ipaexg.ttf ]
then
wget https://ja.osdn.net/dl/ipafonts/IPAexfont00103.zip
unzip IPAexfont00103.zip IPAexfont00103/ipaexg.ttf
mv IPAexfont00103/ipaexg.ttf .
rmdir IPAexfont00103
fi
# 間違い探しの画像を作る
convert -size 480x200 xc:white -gravity North-West -draw "image over 48,42 0,0 '2017c.png'" -fill purple -font ipaexg.ttf -pointsize 28 -draw "text 6,4 '2008年'" -pointsize 18 -draw "text 106,10 'の『小学校学習指導要領解説算数編』より'" -fill blue -pointsize 14 -draw "text 12,162 'http://www.mext.go.jp/component/a_menu/education/micro_detail' text 12,180 '/__icsFiles/afieldfile/2009/06/16/1234931_004_2.pdf#page=128'" 2008d.png
convert -size 480x200 xc:white -gravity North-West -draw "image over 50,24 0,0 '${pic2008}'" -fill purple -font ipaexg.ttf -pointsize 28 -draw "text 6,4 '2017年'" -pointsize 18 -draw "text 106,10 'の『小学校学習指導要領解説算数編』より'" -fill blue -pointsize 14 -draw "text 12,162 'http://www.mext.go.jp/component/a_menu/education/micro_detail' text 12,180 '/__icsFiles/afieldfile/2017/07/25/1387017_4_2.pdf#page=154'" 2017d.png
convert -size 480x464 xc:white -gravity North-West -draw "image over 0,38 0,0 '2008d.png' image over 0,240 0,0 '2017d.png'" -fill darkgreen -font ipaexg.ttf -pointsize 28 -draw "text 144,6 '【間違い探し】'" -fill black -pointsize 14 -draw "text 4,446 '作成者: @takehikom'" -draw "fill none stroke gray25 stroke-width 2 rectangle 1,1 479,39 rectangle 1,39 479,239 rectangle 1,239 479,439" -quality 92 2008-2017a.jpg
# 正解の画像を作る
convert -size 480x200 xc:white -gravity North-West -draw "image over 48,42 0,0 '2017c.png'" -fill purple -font ipaexg.ttf -pointsize 28 -draw "text 6,4 '2017年'" -pointsize 18 -draw "text 106,10 'の『小学校学習指導要領解説算数編』より'" -fill blue -pointsize 14 -draw "text 12,162 'http://www.mext.go.jp/component/a_menu/education/micro_detail' text 12,180 '/__icsFiles/afieldfile/2017/07/25/1387017_4_2.pdf#page=80'" 2017e.png
convert -size 480x200 xc:white -gravity North-West -draw "image over 50,24 0,0 '${pic2008}'" -fill purple -font ipaexg.ttf -pointsize 28 -draw "text 6,4 '2008年'" -pointsize 18 -draw "text 106,10 'の『小学校学習指導要領解説算数編』より'" -fill blue -pointsize 14 -draw "text 12,162 'http://www.mext.go.jp/component/a_menu/education/micro_detail' text 12,180 '/__icsFiles/afieldfile/2009/06/16/1234931_004_2.pdf#page=68'" 2008e.png
convert -size 480x464 xc:white -gravity North-West -draw "image over 0,38 0,0 '2008e.png' image over 0,240 0,0 '2017e.png'" -fill darkgreen -font ipaexg.ttf -pointsize 28 -draw "text 144,6 '【 正  解 】'" -fill black -pointsize 14 -draw "text 4,446 '作成者: @takehikom'" -draw "fill none stroke gray25 stroke-width 2 rectangle 1,1 479,39 rectangle 1,39 479,239 rectangle 1,239 479,439" -quality 92 2008-2017b.jpg
# http://www.mext.go.jp/a_menu/shotou/new-cs/youryou/syokaisetsu/index.htm
# http://www.mext.go.jp/component/a_menu/education/micro_detail/__icsFiles/afieldfile/2009/06/16/1234931_004_2.pdf#page=68
# http://www.mext.go.jp/a_menu/shotou/new-cs/1387014.htm
# http://www.mext.go.jp/component/a_menu/education/micro_detail/__icsFiles/afieldfile/2017/07/25/1387017_4_2.pdf#page=80
# https://ja.osdn.net/projects/ipafonts/releases/49986
# http://www.imagemagick.org/Usage/draw/
# https://firegoby.jp/archives/613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment