From the official website http://blockdiag.com/ja/index.html
The blockdiag series is a group of image generation tools that generate images such as block diagrams from simple text.
"Generate image file from text-based definition file" I tried this.
・ From the official website, for CentOS 6.2 http://blockdiag.com/ja/blockdiag/introduction.html#centos-6-2
・ From the official website, execution method and font settings http://blockdiag.com/ja/blockdiag/introduction.html#id10
▽ Other You can draw a figure without a mouse! I fell in love with 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
▽ From error handling 2
# yum install python-devel zlib-devel libjpeg-devel
▽ From error handling 4
# yum install freetype-devel.x86_64
▽ From error handling 1
# easy_install pillow
# easy_install webcolors
# easy_install funcparserlib
▽ From error handling 3
# easy_install -U reportlab==2.5
▽ Installation confirmation (python package)
# pip freeze | grep -i "blockdiag\|pillow\|webcolors\|funcparserlib"
▽ When specifying the font at runtime
$ blockdiag -f /usr/share/fonts/ipa-gothic/ipag.ttf simple.diag
▽ When defining in $ HOME / .blockdiagrc
$ vi $HOME/.blockdiagrc
--------------------
[blockdiag]
fontpath = /usr/share/fonts/ipa-gothic/ipag.ttf
Run the blockdiag command to generate a block diagram.
First, move to the document root of the web server that can display the image to be created
# cd /var/www/html
http://blockdiag.com/ja/blockdiag/examples.html#simple-diagram
# vi simple.diag
-----------------
blockdiag {
A -> B -> C -> D;
A -> E -> F -> G;
}
・ Generate a block diagram
# blockdiag simple.diag
# blockdiag -Tsvg simple.diag
# blockdiag -Tpdf simple.diag
* From the top, PNG format, SVG format, PDF format
・ Check from the browser http://example.com/simple.png
http://example.com/simple.svg
http://example.com/simple.pdf
http://blockdiag.com/ja/blockdiag/examples.html#mutlilingualization
# vi nippon.diag
-----------------
blockdiag admin {
// Set M17N text using label property.
A [label = "Ki"];
B [label = "Accepted"];
C [label = "Turn"];
D [label = "Conclusion"];
A -> B -> C -> D;
// Use M17N text directly (need to quote).
spring->summer->autumn->winter;
// Use M17N text including symbol characters (need to quote).
"Spring is dawn" -> "summer=Night" -> "autumn.evening" -> "winter&be making an effort";
}
・ Generate a block diagram
# blockdiag nippon.diag
# blockdiag -Tsvg nippon.diag
# blockdiag -Tpdf nippon.diag
* From the top, PNG format, SVG format, PDF format
・ Check from the browser
http://example.com/nippon.png
http://example.com/nippon.svg
http://example.com/nippon.pdf
-If the following error is output when executing the diag command
# 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
-Check that pillow is not installed
# pip freeze | grep -i "pillow\|webcolors\|funcparserlib"
* Pip is a package management system in Python.
・ Pillow installation
# easy_install pillow
▽ The following error after introducing pillow
pkg_resources.DistributionNotFound: webcolors
・ Installation of web colors
# easy_install webcolors
▽ The following error after introducing web colors
pkg_resources.DistributionNotFound: funcparserlib
・ Installation of funcparserlib
# easy_install funcparserlib
・ Introduction confirmation
# pip freeze | grep -i "pillow\|webcolors\|funcparserlib\|reportlab"
Pillow==2.6.0
funcparserlib==0.3.6
webcolors==1.4
▽ When the following error is output during pillow installation
(abridgement)
_imaging.c:3570: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘init_imaging’
error: Setup script exited with error: command 'gcc' failed with exit status 1
・ Introduce the following packages (from the forum)
# 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
・ Countermeasure, pass the following path (from the forum)
# export CFLAGS=-Qunused-arguments
# export CPPFLAGS=-Qunused-arguments
-Execute the installation command again
# easy_install pillow
▽ If you cannot create a block diagram in PDF format
# blockdiag -Tpdf simple.diag
ERROR: unknown format: PDF
▽ Install reportlab
easy_install -U reportlab==2.5
# 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.
▽ When trying to create a sample block diagram including Japanese
# blockdiag nippon.diag
ERROR: The _imagingft C module is not installed
▽ Reference site [python] When PIL gives an import error of _imagingft http://d.hatena.ne.jp/pashango_p/20110919/1316408103
The point is that FreeType2 was not installed when compiling PIL. For Linux (OpenSuse), install the "freetype2-devel" package and then install PIL to solve the problem.
▽ Install freetype-devel
# yum install freetype-devel.x86_64
▽ Uninstall / install PIL (From the official website) Reinstalling the PIL package
# 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
▽ Reinstall 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
▽ After the above settings, when the command was executed again, it was successfully output in PDF format.
# blockdiag nippon.diag
# ls -l nippon.pdf
-rw-r--r--1 root root 20415 October 6 16:47 2014 nippon.pdf
That's it.
Recommended Posts