ImageMagick install support Jbig 支持JBIG PNG

系统环境CentOS6.6
root用户进行的安装
#普通用户的话需要用一些系统目录,权限比较复杂,不易上手。


我的环境需要安装ImageMagick 并且需要用到Jbig,PNG文件类型。

如果你没有任何需求,只是需要使用ImageMagick 即可
那么直接  yum install  ImageMagick ,但是yum安装的缺少很多图片类型的支持。

所以我这里采用的是源码安装的。

#安装依赖
yum install -y  gcc gcc-c++   zlib zlib-devel perl-CPAN    glib2-devel  jasper
yum install -y  libpng libpng-devel        #(支持png格式)

本文章主要描述的是部署ImageMagick的时候,需要支持Jbig,其他图片类型的支持可以查看其它文档,或者直接yum安装,不在此赘述。
此处可根据需求安装,如果没啥需求,都安装上吧,常用的类型都在这里了。
依赖安装(如果只需要JBIG则不需要下面这些依赖)
#sudo yum install -y  libjpeg-devel libjpeg freetype-devel freetype 
#sudo yum install -y  tcl-devel  ghostscript-devel bzip2-devel  libtiff-devel
#libtiff4-dev                          和tiff有关        --with-tiff=yes yes
#   libjpeg-devel libjpeg  支持jpgJPEG v1
#jasper    libjasper-dev 支持jpg2000


mkdir -p  /soft/ImageMagick
cd  /soft/ImageMagick
wget http://downloads.jmagick.org/6.4.0/ImageMagick-6.4.0-0.tar.gz
wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/delegates/jbigkit-2.0.tar.gz

jbigkit-2.0.tar.gz 是Jbig的支持文件,可以google下载。

请严格按照每一步进行执行,否则会报错,报错就删了解压后的目录,重新安装即可。
tar xf jbigkit-2.0.tar.gz 
cd jbigkit 
make CFLAGS="-O3 -fPIC" 

#执行结果无论是否如下都没关系继续往下走。
(cd libjbig; make "CC=gcc" "CFLAGS=-O3 -fPIC") 
make[1]: Entering directory `/soft/ImageMagick/jbigkit/libjbig' 
gcc -O3 -fPIC -c -o jbig.o jbig.c 
gcc -O3 -fPIC -c -o jbig_ar.o jbig_ar.c 
rm -f libjbig.a 
ar rc libjbig.a jbig.o jbig_ar.o 
ranlib libjbig.a 
gcc -O3 -fPIC -c -o tstcodec.o tstcodec.c 
gcc -O3 -fPIC -o tstcodec tstcodec.o jbig.o jbig_ar.o 
gcc -O3 -fPIC -c -o tstcodec85.o tstcodec85.c 
gcc -O3 -fPIC -c -o jbig85.o jbig85.c 
gcc -O3 -fPIC -o tstcodec85 tstcodec85.o jbig85.o jbig_ar.o 
make[1]: Leaving directory `/soft/ImageMagick/jbigkit/libjbig' 
(cd pbmtools; make "CC=gcc" "CFLAGS=-O3 -fPIC") 
make[1]: Entering directory `/soft/ImageMagick/jbigkit/pbmtools' 
gcc -O3 -fPIC -c -o pbmtojbg.o pbmtojbg.c 
pbmtojbg.c:13:18: error: jbig.h: No such file or directory 
pbmtojbg.c: In function ‘usage’: 
pbmtojbg.c:26: error: expected ‘)’ before ‘JBG_VERSION’ 
pbmtojbg.c: In function ‘main’: 
pbmtojbg.c:123: error: storage size of ‘s’ isn’t known 
pbmtojbg.c:129: error: ‘JBG_TPDON’ undeclared (first use in this function) 
pbmtojbg.c:129: error: (Each undeclared identifier is reported only once 
pbmtojbg.c:129: error: for each function it appears in.) 
pbmtojbg.c:129: error: ‘JBG_TPBON’ undeclared (first use in this function) 
pbmtojbg.c:129: error: ‘JBG_DPON’ undeclared (first use in this function) 
pbmtojbg.c:130: error: ‘JBG_ILEAVE’ undeclared (first use in this function) 
pbmtojbg.c:130: error: ‘JBG_SMID’ undeclared (first use in this function) 
pbmtojbg.c:371: error: ‘JBG_DELAY_AT’ undeclared (first use in this function) 
pbmtojbg.c:373: error: ‘JBG_SDRST’ undeclared (first use in this function) 
pbmtojbg.c:416: error: ‘JBG_LRLTWO’ undeclared (first use in this function) 
pbmtojbg.c:417: error: ‘JBG_VLENGTH’ undeclared (first use in this function) 
pbmtojbg.c:421: error: ‘JBG_DPPRIV’ undeclared (first use in this function) 
pbmtojbg.c:422: error: ‘JBG_DPLAST’ undeclared (first use in this function) 
pbmtojbg.c:424: error: ‘JBG_HITOLO’ undeclared (first use in this function) 
pbmtojbg.c:425: error: ‘JBG_SEQ’ undeclared (first use in this function) 
make[1]: *** [pbmtojbg.o] Error 1 
make[1]: Leaving directory `/soft/ImageMagick/jbigkit/pbmtools' 
make: *** [pbm] Error 2 
然后继续执行如下:
CFLAGS=-fPIC
make 
cd libjbig
cp jbig85.h  jbig_ar.h  jbig.h /usr/local/include/ 
cp jbig85.o  jbig_ar.o  jbig.o  libjbig85.a  libjbig.a  tstcodec85.o  tstcodec.o  /usr/local/lib
cp jbig85.o  jbig_ar.o  jbig.o  libjbig85.a  libjbig.a  tstcodec85.o  tstcodec.o  /usr/local/lib64

#然后安装ImageMagick
cd ../../
tar xf ImageMagick-6.4.0-0.tar.gz
cd ImageMagick-6.4.0
./configure 
#此处可以看到支持的类型已经在最后显示出来了。如果缺少你要的图片类型(可以直接yum安装)
#此处经常报错,各种尝试,没有得到很好地解决办法。最终得出来的结论就是按照每一步都按照本文介绍的执行,就能通过。
make
make install

到此安装结束
查看支持的类型  以及图片格式
convert -list format


convert -list format
   Format  Module    Mode  Description
-------------------------------------------------------------------------------
        A* RAW       rw+   Raw alpha samples
       AI  PDF       rw-   Adobe Illustrator CS2
      ART* ART       rw-   PFS: 1st Publisher Clip Art
      ARW  DNG       r--   Sony Alpha Raw Image Format
      AVI* AVI       r--   Microsoft Audio/Visual Interleaved
      AVS* AVS       rw+   AVS X image
        B* RAW       rw+   Raw blue samples
      BIE* JBIG      rw-   Joint Bi-level Image experts Group interchange format (2.0)
      BMP* BMP       rw-   Microsoft Windows bitmap image
     BMP2* BMP       -w-   Microsoft Windows bitmap image v2
     BMP3* BMP       -w-   Microsoft Windows bitmap image v3
      BRF* BRAILLE   -w-   BRF ASCII Braille format
        C* RAW       rw+   Raw cyan samples
  CAPTION* CAPTION   r--   Image caption
      CIN* CIN       rw+   Cineon Image File
      CIP* CIP       -w-   Cisco IP phone image format
     CLIP* CLIP      -w+   Image Clip Mask
     CMYK* CMYK      rw+   Raw cyan, magenta, yellow, and black samples
    CMYKA* CMYK      rw+   Raw cyan, magenta, yellow, black, and opacity samples
      CR2  DNG       r--   Canon Digital Camera Raw Image Format
      CRW  DNG       r--   Canon Digital Camera Raw Image Format
      CUR* CUR       rw-   Microsoft icon
      CUT* CUT       r--   DR Halo
      DCM* DCM       r--   Digital Imaging and Communications in Medicine image
           DICOM is used by the medical community for images like X-rays.  The
           specification, "Digital Imaging and Communications in Medicine
           (DICOM)", is available at http://medical.nema.org/.  In particular,
           see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
           and supplement 61 which adds JPEG-2000 encoding.
      DCR  DNG       r--   Kodak Digital Camera Raw Image File
      DCX* PCX       rw+   ZSoft IBM PC multi-page Paintbrush
      DDS* DDS       r--   Microsoft DirectDraw Surface
    DFONT* TTF       r--   Multi-face font package (Freetype 2.3.11)
      DNG  DNG       r--   Digital Negative
      DOT  DOT       ---   Graphviz
      DPS  DPS       ---   Display Postscript Interpreter
      DPX* DPX       rw+   SMPTE 268M-2003 (DPX 2.0)
           Digital Moving Picture Exchange Bitmap, Version 2.0.
           See SMPTE 268M-2003 specification at http://www.smtpe.org
           
     EPDF  PDF       rw-   Encapsulated Portable Document Format
      EPI  PS        rw-   Encapsulated PostScript Interchange format
      EPS  PS        rw-   Encapsulated PostScript
     EPS2* PS2       -w-   Level II Encapsulated PostScript
     EPS3* PS3       -w+   Level III Encapsulated PostScript
     EPSF  PS        rw-   Encapsulated PostScript
     EPSI  PS        rw-   Encapsulated PostScript Interchange format
      EPT  EPT       rw-   Encapsulated PostScript with TIFF preview
     EPT2  EPT       rw-   Encapsulated PostScript Level II with TIFF preview
     EPT3  EPT       rw+   Encapsulated PostScript Level III with TIFF preview
      FAX* FAX       rw+   Group 3 FAX
           FAX machines use non-square pixels which are 1.5 times wider than they
           are tall but computer displays use square pixels, therefore FAX images
           may appear to be narrow unless they are explicitly resized using a
           geometry of "150x100%".
           
     FITS* FITS      rw-   Flexible Image Transport System
  FRACTAL* PLASMA    r--   Plasma fractal image
      FTS* FTS       rw-   Flexible Image Transport System
        G* RAW       rw+   Raw green samples
       G3* FAX       rw-   Group 3 FAX
      GIF* GIF       rw+   CompuServe graphics interchange format
    GIF87* GIF       rw-   CompuServe graphics interchange format (version 87a)
 GRADIENT* GRADIENT  r--   Gradual passing from one shade to another
     GRAY* GRAY      rw+   Raw gray samples
HISTOGRAM* HISTOGRAM -w-   Histogram of the image
      HTM* HTML      -w-   Hypertext Markup Language and a client-side image map
     HTML* HTML      -w-   Hypertext Markup Language and a client-side image map
      ICB* TGA       rw+   Truevision Targa image
      ICO* ICON      rw+   Microsoft icon
     ICON* ICON      rw-   Microsoft icon
     INFO  INFO      -w+   The image format and characteristics
      IPL* IPL       rw+   IPL Image Sequence
   ISOBRL* BRAILLE   -w-   ISO/TR 11548-1 format
      JBG* JBIG      rw+   Joint Bi-level Image experts Group interchange format (2.0)
     JBIG* JBIG      rw+   Joint Bi-level Image experts Group interchange format (2.0)
      JNG* PNG       rw-   JPEG Network Graphics
           See http://www.libpng.org/pub/mng/ for details about the JNG
           format.
     JPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (62)
      JPG* JPEG      rw-   Joint Photographic Experts Group JFIF format
        K* RAW       rw+   Raw black samples
      K25  DNG       r--   Kodak Digital Camera Raw Image Format
      KDC  DNG       r--   Kodak Digital Camera Raw Image Format
    LABEL* LABEL     r--   Image label
        M* RAW       rw+   Raw magenta samples
      M2V  MPEG      rw+   MPEG Video Stream
      MAP* MAP       rw-   Colormap intensities and indices
      MAT* MAT       rw+   MATLAB image format
    MATTE* MATTE     -w+   MATTE format
     MIFF* MIFF      rw+   Magick Image File Format
      MNG* PNG       rw+   Multiple-image Network Graphics (libpng 1.2.49)
           See http://www.libpng.org/pub/mng/ for details about the MNG
           format.
     MONO* MONO      rw-   Raw bi-level bitmap
      MPC* MPC       rw+   Magick Persistent Cache image format
     MPEG  MPEG      rw+   MPEG Video Stream
      MPG  MPEG      rw+   MPEG Video Stream
      MRW  DNG       r--   Sony (Minolta) Raw Image File
      MSL* MSL       ---   Magick Scripting Language
     MSVG* SVG       -w+   ImageMagick's own SVG internal renderer
      MTV* MTV       rw+   MTV Raytracing image format
      MVG* MVG       rw-   Magick Vector Graphics
      NEF  DNG       r--   Nikon Digital SLR Camera Raw Image File
     NULL* NULL      rw-   Constant image of uniform color
        O* RAW       rw+   Raw opacity samples
      ORF  DNG       r--   Olympus Digital Camera Raw Image File
      OTB* OTB       rw-   On-the-air bitmap
      OTF* TTF       r--   Open Type font (Freetype 2.3.11)
      PAL* UYVY      rw-   16bit/pixel interleaved YUV
     PALM* PALM      rw+   Palm pixmap
      PAM* PNM       rw+   Common 2-dimensional bitmap format
  PATTERN* PATTERN   r--   Predefined pattern
      PBM* PNM       rw+   Portable bitmap format (black and white)
      PCD* PCD       rw-   Photo CD
     PCDS* PCD       rw-   Photo CD
      PCL  PCL       rw-   Printer Control Language
      PCT* PICT      rw-   Apple Macintosh QuickDraw/PICT
      PCX* PCX       rw-   ZSoft IBM PC Paintbrush
      PDB* PDB       rw+   Palm Database ImageViewer Format
      PDF  PDF       rw+   Portable Document Format
     PDFA  PDF       rw+   Portable Document Archive Format
      PEF  DNG       r--   Pentax Electronic File
      PFA* TTF       r--   Postscript Type 1 font (ASCII) (Freetype 2.3.11)
      PFB* TTF       r--   Postscript Type 1 font (binary) (Freetype 2.3.11)
      PFM* PFM       rw+   Portable float format
      PGM* PNM       rw+   Portable graymap format (gray scale)
    PICON* XPM       rw-   Personal Icon
     PICT* PICT      rw-   Apple Macintosh QuickDraw/PICT
      PIX* PIX       r--   Alias/Wavefront RLE image format
    PJPEG* JPEG      rw-   Progessive Joint Photographic Experts Group JFIF
   PLASMA* PLASMA    r--   Plasma fractal image
      PNG* PNG       rw-   Portable Network Graphics (libpng 1.2.49)
           See http://www.libpng.org/ for details about the PNG format.
    PNG24* PNG       rw-   opaque 24-bit RGB (zlib 1.2.3)
    PNG32* PNG       rw-   opaque or transparent 32-bit RGBA
     PNG8* PNG       rw-   8-bit indexed with optional binary transparency
      PNM* PNM       rw+   Portable anymap
      PPM* PNM       rw+   Portable pixmap format (color)
  PREVIEW* PREVIEW   -w-   Show a preview an image enhancement, effect, or f/x
       PS  PS        rw+   PostScript
      PS2* PS2       -w+   Level II PostScript
      PS3* PS3       -w+   Level III PostScript
      PSD* PSD       rw+   Adobe Photoshop bitmap
     PTIF* TIFF      rw-   Pyramid encoded TIFF
      PWP* PWP       r--   Seattle Film Works
        R* RAW       rw+   Raw red samples
      RAF  DNG       r--   Fuji CCD-RAW Graphic File
      RAS* SUN       rw+   SUN Rasterfile
      RGB* RGB       rw+   Raw red, green, and blue samples
     RGBA* RGB       rw+   Raw red, green, blue, and alpha samples
     RGBO* RGB       rw+   Raw red, green, blue, and opacity samples
      RLA* RLA       r--   Alias/Wavefront image
      RLE* RLE       r--   Utah Run length encoded image
      SCR* SCR       r--   ZX-Spectrum SCREEN$
      SCT* SCT       r--   Scitex HandShake
      SFW* SFW       r--   Seattle Film Works
      SGI* SGI       rw+   Irix RGB image
    SHTML* HTML      -w-   Hypertext Markup Language and a client-side image map
      SR2  DNG       r--   Sony Raw Format 2
      SRF  DNG       r--   Sony Raw Format
  STEGANO* STEGANO   r--   Steganographic image
      SUN* SUN       rw+   SUN Rasterfile
      SVG* SVG       -w+   Scalable Vector Graphics
     SVGZ* SVG       -w+   Compressed Scalable Vector Graphics
     TEXT* TXT       rw+   Text
      TGA* TGA       rw+   Truevision Targa image
THUMBNAIL* THUMBNAIL -w+   EXIF Profile Thumbnail
     TIFF* TIFF      rw+   Tagged Image File Format (LIBTIFF, Version 3.9.4)
   TIFF64* TIFF      ---   Tagged Image File Format (64-bit) (LIBTIFF, Version 3.9.4)
     TILE* TILE      r--   Tile image with a texture
      TIM* TIM       r--   PSX TIM
      TTC* TTF       r--   TrueType font collection (Freetype 2.3.11)
      TTF* TTF       r--   TrueType font (Freetype 2.3.11)
      TXT* TXT       rw+   Text
     UBRL* BRAILLE   -w-   Unicode Text format
      UIL* UIL       -w-   X-Motif UIL table
     UYVY* UYVY      rw-   16bit/pixel interleaved YUV
      VDA* TGA       rw+   Truevision Targa image
    VICAR* VICAR     rw-   VICAR rasterfile format
      VID* VID       rw+   Visual Image Directory
     VIFF* VIFF      rw+   Khoros Visualization image
      VST* TGA       rw+   Truevision Targa image
     WBMP* WBMP      rw-   Wireless Bitmap (level 0) image
      WMF* WMF       ---   Windows Meta File
      WMZ* WMZ       ---   Compressed Windows Meta File
      WPG* WPG       r--   Word Perfect Graphics
      X3F  DNG       r--   Sigma Camera RAW Picture File
      XBM* XBM       rw-   X Windows system bitmap (black and white)
       XC* XC        r--   Constant image uniform color
      XCF* XCF       r--   GIMP image
      XPM* XPM       rw-   X Windows system pixmap (color)
      XPS  XPS       r--   Microsoft XML Paper Specification
       XV* VIFF      rw+   Khoros Visualization image
        Y* RAW       rw+   Raw yellow samples
    YCbCr* YCbCr     rw+   Raw Y, Cb, and Cr samples
   YCbCrA* YCbCr     rw+   Raw Y, Cb, Cr, and opacity samples
      YUV* YUV       rw-   CCIR 601 4:1:1 or 4:2:2


* native blob support



#如果是root用户进行安装,并且root使用这个软件或命令,或者启动的服务,下面这个可以不用执行。
#因为我的环境umask=027,所以普通用户执行的时候看不到支持的类,需要赋权才行。
cd /usr/local/
for i in include  lib  lib64 share
do 
    find $i -type d  -exec chmod 755 {} \;
    find $i -type f -exec chmod 644 {} \;
done


###################################################
最常见的报错:
mv -f coders/.deps/coders_jp2_la-jp2.Tpo coders/.deps/coders_jp2_la-jp2.Plo
/bin/sh ./libtool --silent --tag=CC   --mode=link gcc  -g -O2 -Wall -W -pthread -no-undefined -export-symbols-regex ".*" -module -avoid-version -lfreetype -o coders/jp2.la -rpath /usr/local/lib/ImageMagick-6.4.0/modules-Q16/coders coders/coders_jp2_la-jp2.lo magick/libMagickCore.la -ljasper -ljpeg -lm 
/usr/bin/ld: /usr/local/lib/libjasper.a(jas_stream.o): relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libjasper.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [coders/jp2.la] Error 1
make[1]: Leaving directory `/soft/ImageMagick_install/ImageMagick-6.4.0'
make: *** [all] Error 2
原因就是:
locatejp2.la
发现原来这个是yum安装出来的文件。
已经yum安装了ImageMagick-6.7.2.7-2.el6.x86_64    需要卸载重新安装即可。
yum removeImageMagick-6.7.2.7-2.el6.x86_64
然后
rm -rf ImageMagick-6.4.0 jbigkit 
tar xf jbigkit-2.0.tar.gz 
cd jbigkit 
make CFLAGS="-O3 -fPIC" 

CFLAGS=-fPIC
make 
cd libjbig
\cp jbig85.h  jbig_ar.h  jbig.h  /usr/local/include/ 
\cp jbig85.o  jbig_ar.o  jbig.o  libjbig85.a  libjbig.a  tstcodec85.o  tstcodec.o  /usr/local/lib
\cp jbig85.o  jbig_ar.o  jbig.o  libjbig85.a  libjbig.a  tstcodec85.o  tstcodec.o  /usr/local/lib64

cd ../../
tar xf ImageMagick-6.4.0-0.tar.gz
cd ImageMagick-6.4.0
 ./configure 
make
make install 
#到此安装完毕
 convert -list format
#####################################################################
#如果报错如下。
make  all-am
make[1]: Entering directory `/soft/ImageMagick_install/ImageMagick-6.4.0'
/bin/sh ./libtool --silent --tag=CC   --mode=link gcc  -g -O2 -Wall -W -pthread -no-undefined -export-symbols-regex ".*" -module -avoid-version -lfreetype -o coders/jp2.la -rpath /usr/local/lib/ImageMagick-6.4.0/modules-Q16/coders coders/coders_jp2_la-jp2.lo magick/libMagickCore.la -ljasper -ljpeg -lm 
/usr/bin/ld: cannot find -ljasper
collect2: ld returned 1 exit status
make[1]: *** [coders/jp2.la] Error 1
make[1]: Leaving directory `/soft/ImageMagick_install/ImageMagick-6.4.0'
make: *** [all] Error 2
解决:
locate jp2.la
 rm -f  /usr/local/lib/libjasper.a    /usr/local/lib/libjasper.la
rm -rf  /usr/local/include/jasper/
rm -rf ImageMagick-6.4.0

tar xf ImageMagick-6.4.0-0.tar.gz 
cd tar xf ImageMagick
./configure
make 
make install
##########################################################
报错如下:
mv -f coders/.deps/coders_jbig_la-jbig.Tpo coders/.deps/coders_jbig_la-jbig.Plo
/bin/sh ./libtool --silent --tag=CC   --mode=link gcc  -g -O2 -Wall -W -pthread -no-undefined -export-symbols-regex ".*" -module -avoid-version  -o coders/jbig.la -rpath /usr/local/ImageMagick/lib/ImageMagick-6.4.0/modules-Q16/coders coders/coders_jbig_la-jbig.lo magick/libMagickCore.la -ljbig
/usr/bin/ld: /usr/local/lib64/libjbig.a(jbig.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib64/libjbig.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [coders/jbig.la] Error 1
make[1]: Leaving directory `/soft/ImageMagick/ImageMagick-6.4.0'
make: *** [all] Error 2
原因: 编译jbigkit的时候
使用了错误的编译方式
###############   错误编译方式  ################
#如果直接
make 
#其实和先设置 CFLAGS=-fPIC,然后在make实际是一样的。生成的文件大小和报错都一样的,都是错误的编译方式。
CFLAGS=-fPIC
make
###############   错误编译方式  #################
真正的正确方式应该是:
make CFLAGS="-O3 -fPIC"
CFLAGS=-fPIC
make

解决方式:
rm -rf jbigkit
tar xf jbigkit-2.0.tar.gz 
cd  jbigkit
make CFLAGS="-O3 -fPIC"
CFLAGS=-fPIC
make
然后在拷贝到对应目录后,重新编译ImageMagick即可

















你可能感兴趣的:(linux,类型转换,图片处理,ImageMagick,JBIG)