Chinaunix

标题: JMAGIC 处理网站图片的好工具 [打印本页]

作者: dominic_80    时间: 2011-12-19 14:02
标题: JMAGIC 处理网站图片的好工具

LINUX下安装JMAGIC

 

 

一、安装准备工作

1 1)export LD_LIBRARY_PATH=/usr/local/lib
2 2)added "/usr/local/lib" to /etc/ld.so.conf , 
然后再执行ldconfig命令.


二、开始安装

1)
安装libjpg
wget
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar -xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --enable-shared
make
make test
make install

2)
安装libpng
wget
http://easynews.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.16.tar.bz2
tar -xvjf libpng-1.2.16.tar.bz2
./configure
make

make install

3)
安装Freetype
wget
http://superb-west.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.2.tar.bz2
tar -xjvf freetype-2.3.2.tar.bz2
cd freetype-2.3.2

./configure

make install
cp objs/.libs/*.so* /usr/local/lib/
cp -rv include/* /usr/local/include/

4)
安装Ghostscript
wget
http://umn.dl.sourceforge.net/sourceforge/ghostscript/ghostscript-8.54-gpl.tar.bz2
tar xjvf ghostscript-8.54-gpl.tar.bz2
cd ghostscript-8.54-gpl
./configure
make
make install

5
)安装Ghostscript fonts
wget
http://internap.dl.sourceforge.net/sourceforge/gs-fonts/ghostscript-fonts-std-8.11.tar.gz
tar -xvzf ghostscript-fonts-std-8.11.tar.gz
cp -rv fonts /usr/local/share/ghostscript/

6
)安装ImageMagick   
wget
ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.3.2-9.tar.bz2
tar -xjvf ImageMagick-6.3.2-9.tar.bz2
cd ImageMagick-6.3.2
./configure --without-perl --without-magick-plus-plus –prefix=/usr/local/ImageMagick

export PATH=$PATH:/usr/local/ImageMagick/bin
编辑:/etc/ld.so.conf,加入
/lib

/usr/lib

/lib64

/usr/local/ImageMagick/lib

/usr/local/lib


执行:ldconfig  查看是否有异常..

确定有以下的配置信息出现:
Ghostscript None gs (8.54)
FreeType --with-freetype=yes yes
JPEG v1 --with-jpeg=yes yes
PNG --with-png=yes yes

接着,

make

make install(run as root)

如果在安装后,系统报字体找不到,把usr/share/fonts/type1字体考到目录/usr/share/ghostscript/fonts/,就可以了。

---------------------------------------------------------------------

 

7) JMAGICK的安装

./configure --prefix=/usr/local/JMagick --with-java-home=/usr/local/jdk1.6.0_07/

make

make install

 

三、测试部分

1.测试代码:

import magick.*;

 

public class My{

 

        public My(){

 

 

        }

 

        public static void main(String[] args){

 

                try{

                        MagickImage image = new MagickImage(new ImageInfo("sun.jpg"));

                        int scalex = 60;

                        int scaley = 60;

                        MagickImage small = image.scaleImage(scalex, scaley);

                        small.setFileName("qqq" + ".jpg");

                        small.writeImage(new ImageInfo());

                }catch(Exception e){

                        e.printStackTrace();

                }

        }

}

 

 

2.测试语句写在My.java ,My.java文件可以放在任何位置。

javac My.java (该命令编译生成JAVA类)

然后上传一张图片,名字根据My.java文件内指定的测试图片命名为sun,jpg

java My

如果能生成qqq.jpg图片,测试成功。

 






欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2