7 Feb 2007
Netpbmの導入
http://social-science-study.blogspot.com/2006/11/netpbm.html
Thursday, November 02, 2006
Tgifで作成した画像をWordなどに貼る場合、EPSではなくPNGとして保存する必要がありますが、そのためにはNetpbmというイメージ変換
パッケージを導入する必要があります。(Tgifのインストールはここを参照)そのためには、先に
lintool、libpng、libjpeg、libtiff を導入しておく必要があります。ちなみに、libpng はすでにここで導入の仕方を紹介しているので、ここでは省略します。また、一番最初
に libtool
をインストールする必要があります。ちなみに、開発環境の導入は済んでいるものとして話を進めます。(XcodeToolsのインストールはここを参照)
libtool
まずここから最新版(現時点ではGNU Libtool
1.5.23a)(mine is libtool 1.5.22)
をダウンロードして解凍します。解凍したディレクトリがデスクトップ(~/Desktop)であるとすると、ターミナルから、以下の様に
してコンパイルしてインストールします。
cd ~/Desktop/libtool-1.5.23a
./configure
make
sudo make install
libjpeg
こ
こか
ら最新版(現時点ではjpegsrc.v6b.tar.gz)をダウンロードして解凍します。同様に、解凍したディレクトリがデスクトップ
(~/Desktop)であるとすると、ターミナルから、以下の様にしてコンパイルしてインストールします。以下では、共有ライブラリにリンクを貼りたい
ので、 --enable-shared というオプションを指定しています。また、libtool
のシンボリックリンクを貼っているのは、Makefileがどうやらlibtoolの呼び出しに./libtoolと記述していてエラーを吐くためです。
(単にMakefileの編集が面倒なだけです)
cd ~/Desktop/jpeg-6b
./configure --enable-shared
ln -s /usr/local/bin/libtool ./
make
sudo make install
libtiff
ここから最新版(現時点ではtiff-3.8.2.tar.gz)をダウン
ロードして解凍します。同様に、解凍したディレクトリがデスクトップ(~/Desktop)であるとすると、ターミナルから、以下の様にしてコンパイルし
てインストールします。
cd ~/Desktop/tiff-3.8.2
./configure
make
sudo make install
libpng
Dowload the latest version at http://www.libpng.org/pub/png/libpng.html
(it's now 1.2.24). Then
gunzip libpng-1.2.24.tar.gz
tar -xvf libpng-1.2.24.tar
cd libpng-1.2.24
./configure
make
sudo make install
Netpbm
以上で予備的な段階は終了です。次に、Netpbmの最新版(現時点では10.26.33)(mine is 10.26.49) をここからダウンロードして解凍します。デスクトップ上
(~/Desktop)に解凍したとすると、まず以下の様にしてMakefileを生成します。
cd ~/netpbm-10.26.33
./configure
このとき、configure を行うとこんな
感じの
プロセスを辿ることになりますが、今回は全てデフォルト値を選んでいます。(無理に変えるとコンパイル時にエラーの原因になるので、分からなければデフォ
ルト値のままがいいでしょう)これでMakefileが生成されたら、コンパイルしてインストールすることになります。
閉じる
localhost:~/Desktop/netpbm-10.26.33 ユーザー名$ ./configure
This is the Netpbm configurator. It is an interactive dialog that helps you build the file 'Makefile.config' and prepare to build Netpbm.
Do not be put off by all the questions. Configure gives you the opportunity to make a lot of choices, but you don't have to. If you don't have reason to believe you're smarter than Configure, Just take the defaults (hit ENTER) and don't sweat it.
If you are considering having a program feed answers to the questions below, please read doc/INSTALL, because that's probably the wrong thing to do.
Hit ENTER to begin.
Which of the following best describes your platform? gnu GNU/Linux sun Solaris or SunOS hp HP-UX aix AIX win Windows/DOS (Cygwin, DJGPP, Mingw32) tru64 Tru64 irix Irix bsd NetBSD, BSD/OS openbsd OpenBSD freebsd FreeBSD darwin Darwin or Mac OS X amigaos Amiga unixware Unixware sco SCO OpenServer beos BeOS none none of these are even close
Platform [darwin] ==>
Where will the Netpbm shared library reside once installed? Enter 'default' if it will reside somewhere that the shared library loader will find it automatically. Otherwise, this directory will get built into the Netpbm programs.
Netpbm shared library directory [default] ==> Do you want a regular build or a merge build? If you don't know what this means, take the default or see doc/INSTALL
regular or merge [regular] ==>
Do you want libnetpbm to be statically linked or shared?
static or shared [shared] ==>
What header file defines uint32_t, etc.?
(Doing test compiles to choose a default for you -- ignore errors) Doing test compile: cc -c -o /tmp/netpbm0.o /tmp/netpbm0.c
'#include' argument or NONE [<inttypes.h>] ==>
The following questions concern the subroutine libraries that are Netpbm prerequisites. Every library has a compile-time part (header files) and a link-time part. In the case of a shared library, these are both part of the "development" component of the library, which may be separately installable from the runtime shared library. For each library, you must give the filename of the link library. If it is not in your linker's default search path, give the absolute pathname of the file. In addition, you will be asked for the directory in which the library's interface headers reside, and you can respond 'default' if they are in your compiler's default search path.
If you don't have the library on your system, you can enter 'none' as the library filename and the builder will skip any part that requires that library.
What is your JPEG (graphics format) library? library filename or 'none' [libjpeg.so] ==> Where are the interface headers for it? JPEG header directory [default] ==>
What is your TIFF (graphics format) library? library filename or 'none' [libtiff.so] ==> Where are the interface headers for it? TIFF header directory [default] ==>
What is your PNG (graphics format) library? library filename or 'none' [libpng.so] ==> Where are the interface headers for it? PNG header directory [default] ==>
What is your Z (compression) library? library filename or 'none' [libz.so] ==> Where are the interface headers for it? Z header directory [default] ==>
What URL will you use for the main Netpbm documentation page? This information does not get built into any programs or libraries. It does not make anything actually install that web page. It is just for including in legacy man pages.
Documentation URL [http://netpbm.sourceforge.net/doc/] ==>
Doing test compile: cc -c -o /tmp/netpbm0.o /tmp/netpbm0.c /tmp/netpbm0.c:3:21: error: jpeglib.h: No such file or directory
WARNING: You said the compile-time part of the JPEG library (the header files) is in the compiler's default search path, but a test compile failed to confirm that. If your configuration is exotic, the test compile might just be wrong, but otherwise the Netpbm build will fail.
To fix this, either install the JPEG library there or re-run Configure and answer the question about the JPEG library differently.
Doing test compile: cc -c -o /tmp/netpbm0.o /tmp/netpbm0.c Doing test compile: cc -c -o /tmp/netpbm0.o /tmp/netpbm0.c
We have created the file 'Makefile.config'. Note, however, that we guessed a lot at your configuration and you may want to look at Makefile.config and edit it to your requirements and taste before doing the make.
Now you may proceed with 'make'
閉じる
make
make package
sudo ./installnetpbm
ここで、コンパイルが成功して installnetpbm を実行すると、こんな
感じのプロセスを辿ります。今回も全てデフォルト値を使っています。
閉じる
localhost:~/Desktop/netpbm-10.26.33 ユーザー名$ sudo ./installnetpbm Welcome to the Netpbm install dialogue. We will now proceed to interactively install Netpbm on this system.
You must have already built Netpbm and then packaged it for installation by running 'make package'. See the INSTALL file.
Where is the install package you created with 'make package'? package directory (/tmp/netpbm) ==>
Enter the default prefix for installation locations. I will use this in generating defaults for the following prompts to save you typing. If you plan to spread Netpbm across your system, enter '/'.
install prefix (/usr/local/netpbm) ==>
No directory named '/usr/local/netpbm' exists. Do you want to create it? Y(es) or N(o) (Y) ==> Y Where do you want the programs installed?
program directory (/usr/local/netpbm/bin) ==>
Installing programs... Done.
Where do you want the shared library installed?
shared library directory (/usr/local/netpbm/lib) ==>
Installing shared libraries... done.
In order for the Netpbm shared library to be found when you invoke A Netpbm program, you must either set an environment variable to tell where to look for it, or you must put its location in the shared library location cache. Do you want to run Ldconfig now to put the Netpbm shared library in the cache? This works only if you have installed the library in a standard location.
Y(es) or N(o) (Y) ==> Y Unable to run Ldconfig. Ldconfig failed. You will have to fix this later.
Where do you want the static link library installed?
static library directory (/usr/local/netpbm/lib) ==>
Installing link libraries. done.
Where do you want the data files installed?
data file directory (/usr/local/netpbm/lib) ==>
Installing data files... done.
Where do you want the library interface header files installed?
header directory (/usr/local/netpbm/include) ==>
Installing interface header files... done.
Where do you want the man pages installed?
man page directory (/usr/local/netpbm/man) ==>
Installing man pages... done.
You don't have a /etc/manweb.conf, which is the configuration file for the 'manweb' program, which is a quick way to get to Netpbm documentation. Would you like to create one now? create /etc/manweb.conf (Y) ==> Y Your manweb.conf file says top level documentation is in /usr/man/web, but you installed netpbm.url in /usr/local/netpbm/man/web. Do you want to create a symlink in /usr/man/web now? create symlink (Y/N) (Y) ==> Y Failed to create symbolic link from /usr/man/web/netpbm.url to /usr/local/netpbm/man/web/netpbm.url. Error is No such file or directory
Installation is complete (except where previous error messages have indicated otherwise).
閉じる
<補足>
最後に、netpbm の実行ファイル群がサーチパスに含まれる様に、.bashrc に /usr/local/netpbm/bin
を書き足します。(例えば以下の様な記述になります)
export PATH=${PATH}: 既に記述されているパス :/usr/local/netpbm/bin
さらに、ダイナミックライブラリの読み込みがこのままではどうも上手くいかない様なので、以下の様にしてシンボリックリンクを貼ります。
sudo ln -s /usr/local/netpbm/lib/*.dylib /usr/local/lib
これで導入が完了したので、Tgifで作成した図を EPS 以外の形式、JPEGやPNG、TIFF
など、で保存することができる様になります。保存形式を変更するには、Tgifの左上のボタンをクリックして保存形式を選びます。
Trying out, use
pnmtopng file.pbm > file.png
|