프레임맵 생성 도구blockdiag를 도입하려고 했습니다.

12216 단어 blockdiagCentOSPython

입문


■ Blockdiag는


공식 사이트
http://blockdiag.com/ja/index.html
blockdiag 시리즈는 간단한 텍스트에서 프레임맵 등 이미지를 생성하는 이미지 생성 도구군입니다.

■ 이번에 시도한 일


"텍스트 기반 정의 파일에서 이미지 파일 생성"
이거 한번 해봤어요.

■ 웹 사이트 참조


• 공식 사이트에 CentOS6.2 시 표시
http://blockdiag.com/ja/blockdiag/introduction.html#centos-6-2
• 공식 사이트에서 실행 방법, 글꼴 설정
http://blockdiag.com/ja/blockdiag/introduction.html#id10
기타
마우스가 없으면 그림을 그릴 수 있다!저는 Blockdiag를 사랑하게 됐어요.
http://d.hatena.ne.jp/torazuka/20110620/blockdiag

배치


■ 환경


AWS EC2(CentOS 6.5)
Python 2.6.6

■ 설치

# yum install python-setuptools python-imaging ipa-gothic-fonts
# easy_install blockdiag
※easy_install은python의setuptools에 포함된 명령행 도구입니다.웹에서 소프트웨어 패키지를 다운로드하고 설치합니다.
오류 처리 2
# yum install python-devel zlib-devel libjpeg-devel
오류 처리 4
# yum install freetype-devel.x86_64
오류 처리 1
# easy_install pillow
# easy_install webcolors
# easy_install funcparserlib
오류 처리 3
# easy_install -U reportlab==2.5
설치 확인(python 패키지)
# pip freeze | grep -i "blockdiag\|pillow\|webcolors\|funcparserlib"

프로비저닝


■ 글꼴


= 실행할 때 글꼴을 지정할 때
$ blockdiag -f /usr/share/fonts/ipa-gothic/ipag.ttf simple.diag
▽$HOME/.blockdiagrc에서 정의할 때
$ vi $HOME/.blockdiagrc
--------------------
[blockdiag]
fontpath = /usr/share/fonts/ipa-gothic/ipag.ttf

동작 확인


상자도를 생성하기 위해 blockdiag 명령을 실행합니다.
※ 공식 사이트에서 구가하는 example을 저장하지 않아 수동으로 제작합니다.

■ 디렉토리 이동


먼저 만들 그림을 표시할 수 있는 웹 서버의documentroot 산하로 이동합니다.
# cd /var/www/html

■ 단순한 틀보다

# vi simple.diag
-----------------
blockdiag {
   A -> B -> C -> D;
   A -> E -> F -> G;
}
/상자도 생성
# blockdiag simple.diag
# blockdiag -Tsvg simple.diag
# blockdiag -Tpdf simple.diag
※上からPNG形式、SVG形式、PDF形式
브라우저에서 확인
http://example.com/simple.png

http://example.com/simple.svg

http://example.com/simple.pdf

■ 일본어 사용보다

# vi nippon.diag
-----------------
blockdiag admin {
   // Set M17N text using label property.
   A [label = "起"];
   B [label = "承"];
   C [label = "転"];
   D [label = "結"];

   A -> B -> C -> D;

   // Use M17N text directly (need to quote).
   春 -> 夏 -> 秋 -> 冬;

   // Use M17N text including symbol characters (need to quote).
   "春は 曙" -> "夏 = 夜" -> "秋.夕暮れ" -> "冬 & つとめて";
}
/상자도 생성
# blockdiag nippon.diag
# blockdiag -Tsvg nippon.diag
# blockdiag -Tpdf nippon.diag
※上からPNG形式、SVG形式、PDF形式
브라우저에서 확인
http://example.com/nippon.png

http://example.com/nippon.svg

http://example.com/nippon.pdf

지원


■ 오류 처리 1


· diag 명령을 실행할 때 다음 오류를 출력할 때
# blockdiag simple.diag
--------------------
Traceback (most recent call last):
  File "/usr/bin/blockdiag", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: Pillow
・ 필로우가 설치되어 있지 않은지 확인
# pip freeze | grep -i "pillow\|webcolors\|funcparserlib"
※pipとは、Pythonにおけるパッケージ管理システム
・ 필로우 설치
# easy_install pillow
pillow 가져오기 후 다음 오류
pkg_resources.DistributionNotFound: webcolors
・webcolors 설치
# easy_install webcolors
= 웹colors를 가져온 후 다음 오류
pkg_resources.DistributionNotFound: funcparserlib
・funcparserlib 설치
# easy_install funcparserlib
가져오기 확인
# pip freeze | grep -i "pillow\|webcolors\|funcparserlib\|reportlab"
Pillow==2.6.0
funcparserlib==0.3.6
webcolors==1.4

■ 오류 처리 2


pillow 설치에서 다음 오류를 출력할 때
(省略)
_imaging.c:3570: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘init_imaging’
error: Setup script exited with error: command 'gcc' failed with exit status 1
/다음 패키지 가져오기(포럼에서 제공)
# yum install python-devel zlib-devel libjpeg-devel
------
zlib-devel-1.2.3-29.el6.x86_64
libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64
python-devel-2.6.6-52.el6.x86_64
/대응, 다음 경로를 통해 (포럼에서)
# export CFLAGS=-Qunused-arguments
# export CPPFLAGS=-Qunused-arguments
/설치 명령 다시 실행
# easy_install pillow

■ 오류 처리 3


= PDF 형식의 상자도를 만들 수 없는 경우
# blockdiag -Tpdf simple.diag
ERROR: unknown format: PDF
= reportlab 설치
easy_install -U reportlab==2.5
※ 주석: 최신 리포트랩 3.1.8은 내가 가져온python을 지원하지 않기 때문에 이전 버전을 가져왔습니다.
# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)

>>> import reportlab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/reportlab-3.1.8-py2.6-linux-x86_64.egg/reportlab/__init__.py", line 11, in <module>
    raise ImportError("""reportlab requires Python 2.7+ or 3.3+; 3.0-3.2 are not supported.""")
ImportError: reportlab requires Python 2.7+ or 3.3+; 3.0-3.2 are not supported.

■ 오류 처리 4


일본어가 포함된 샘플 상자도를 만들려면
# blockdiag nippon.diag
ERROR: The _imagingft C module is not installed
참고 사이트
[python] PIL에서_imagingft 가져오기 오류가 발생했을 때
http://d.hatena.ne.jp/pashango_p/20110919/1316408103
주요 원인은 PIL을 컴파일할 때 FreeType2를 설치하지 않았기 때문이다.
Linux(OpenSuse)의 경우 "freetype2-devel"패키지를 설치한 후 PIL을 설치하면 해결됩니다.
= freetype-devel 설치
# yum install freetype-devel.x86_64
= PIL 제거 및 설치
PIL 패키지 재설치
# easy_install -m PIL
# \rm -rf /usr/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-x86_64.egg

# easy_install PIL
Pillow 재설치
# easy_install -m pillow
# \rm -rf /usr/lib/python2.6/site-packages/Pillow-2.6.0-py2.6-linux-x86_64.egg

# easy_install pillow
= 위 설정 후 명령을 다시 실행하면 PDF 형식으로 출력됩니다.
# blockdiag nippon.diag

# ls -l nippon.pdf
-rw-r--r-- 1 root root 20415 10月  6 16:47 2014 nippon.pdf
여기서 마치겠습니다.

좋은 웹페이지 즐겨찾기