ImageMagick ™ 是一个免费的创建、编辑、合成图片的软件。它可以读取、转换、写入多种格式的图片。图片切割、颜色替换、各种效果的应用,图片的旋转、组合,文本,直线,多边形,椭圆,曲线,附加到图片伸展旋转。ImageMagick是免费软件:全部源码开放,可以自由使用,复制,修改,发布。它遵守GPL许可协议。它可以运行于大多数的操作系统。ImageMagick的大多数功能的使用都来源于命令行工具。通常来说,它可以支持以下程序语言: Perl, C, C++, Python, PHP, Ruby, Java;现成的ImageMagick接口(PerlMagick, Magick++, PythonMagick, MagickWand for PHP, RubyMagick, and JMagick)是可利用的。这使得自动的动态的修改创建图片变为可能。

本节介绍deepin 15下安装ImageMagick

一、imagemagick下载
https://imagemagick.org/download/ImageMagick.tar.gz

二、解压文件

eric@eric-PC:~/Documents/work/linux-c/ImageMagick-7.0.10-6$ ls
aclocal.m4   common.shi     config.status  ImageMagick.spec     Install-mac.txt      libtool    Magick++      Magickshr.opt  Makefile.in  Platforms.txt   tests       www
AUTHORS.txt  common.shi.in  configure      ImageMagick.spec.in  Install-unix.txt     LICENSE    MagickCore    MagickWand     NEWS.txt     QuickStart.txt  utilities
ChangeLog    config         configure.ac   images               Install-vms.txt      local.exp  magick.sh     Makefile       NOTICE       README.txt      version.sh
coders       config.log     filters        index.html           Install-windows.txt  m4         magick.sh.in  Makefile.am    PerlMagick   scripts         winpath.sh

三、配置
运行 ./configure

eric@eric-PC:~/Documents/work/linux-c/ImageMagick-7.0.10-6$ ./configure

完成后,可以看到相关的包是否检测到

               Option                        Value
------------------------------------------------------------------------------
Shared libraries  --enable-shared=yes		yes
Static libraries  --enable-static=yes		yes
Build utilities   --with-utilities=yes		yes
Module support    --with-modules=no		no
GNU ld            --with-gnu-ld=yes		yes
Quantum depth     --with-quantum-depth=16	16
High Dynamic Range Imagery
                  --enable-hdri=yes		yes

Install documentation:				yes

Memory allocation library:
  JEMalloc          --with-jemalloc=no		no
  TCMalloc          --with-tcmalloc=no		no
  UMem              --with-umem=no		no

Delegate library configuration:
  BZLIB             --with-bzlib=yes		no
  Autotrace         --with-autotrace=no		no
  DJVU              --with-djvu=yes		no
  DPS               --with-dps=yes		no
  FFTW              --with-fftw=yes		no
  FLIF              --with-flif=yes		no
  FlashPIX          --with-fpx=yes		no
  FontConfig        --with-fontconfig=yes	no
  FreeType          --with-freetype=yes		no
  Ghostscript lib   --with-gslib=no		no
  Graphviz          --with-gvc=yes		no
  HEIC              --with-heic=yes             no
  JBIG              --with-jbig=yes		no
  JPEG v1           --with-jpeg=yes		no
  JPEG XL           --with-jxl=yes    no
  LCMS              --with-lcms=yes		no
  LQR               --with-lqr=yes		no
  LTDL              --with-ltdl=yes		no
  LZMA              --with-lzma=yes		no
  Magick++          --with-magick-plus-plus=yes	yes
  OpenEXR           --with-openexr=yes		no
  OpenJP2           --with-openjp2=yes		no
  PANGO             --with-pango=yes		no
  PERL              --with-perl=no		no
  PNG               --with-png=yes		no
  RAQM              --with-raqm=yes		no
  RAW               --with-raw=yes 	   	no
  RSVG              --with-rsvg=no		no
  TIFF              --with-tiff=yes		no
  WEBP              --with-webp=yes		no
  WMF               --with-wmf=yes		no
  X11               --with-x=			yes
  XML               --with-xml=yes		yes
  ZLIB              --with-zlib=yes		yes
  ZSTD              --with-zstd=yes		no

其中两个关键的:

JPEG v1           --with-jpeg=yes		no
PNG               --with-png=yes		no

如果之前未安装过 jpeg和png对应的lib的话,这个两个会是no,那么ImageMagick将不支持主流的jpeg、png图片处理。

四、增加ImageMagick,jpeg、png支持

eric@eric-PC:~/Documents/work/linux-c/ImageMagick-7.0.10-6$ sudo apt-get install libpng-dev libjpeg-dev

安装libpng和libjpeg后,可以看到系统 中已经有png 和jpeg支持

eric@eric-PC:/usr/bin$ ls *png*
libpng16-config  libpng-config  pngfix  png-fix-itxt  pngtopnm  pnmtopng
eric@eric-PC:/usr/bin$ ls *jpeg*
cjpeg  djpeg  jpegexiforient  jpegtopnm  jpegtran  pnmtojpeg  ppmtojpeg
eric@eric-PC:/usr/bin$ 

再次进行配置./configure即可看到

JPEG v1           --with-jpeg=yes		yes
PNG               --with-png=yes		yes

五、配置完成,make,make install

eric@eric-PC:~/Documents/work/linux-c/ImageMagick-7.0.10-6$ make
eric@eric-PC:~/Documents/work/linux-c/ImageMagick-7.0.10-6$ sudo make install

安装之后,可以看到系统目录/usr/local/lib

eric@eric-PC:/usr/local/lib$ ls *Magick*
libMagick++-7.Q16HDRI.a   libMagick++-7.Q16HDRI.so.4      libMagickCore-7.Q16HDRI.la    libMagickCore-7.Q16HDRI.so.7.0.0  libMagickWand-7.Q16HDRI.so
libMagick++-7.Q16HDRI.la  libMagick++-7.Q16HDRI.so.4.0.0  libMagickCore-7.Q16HDRI.so    libMagickWand-7.Q16HDRI.a         libMagickWand-7.Q16HDRI.so.7
libMagick++-7.Q16HDRI.so  libMagickCore-7.Q16HDRI.a       libMagickCore-7.Q16HDRI.so.7  libMagickWand-7.Q16HDRI.la        libMagickWand-7.Q16HDRI.so.7.0.0

ImageMagick-7.0.10:
config-Q16HDRI

六、测试
查看版本,说明已将安装成功

@eric-PC:~/Documents/work/linux-c/ImageMagick-7.0.10-6$ convert -version
Version: ImageMagick 7.0.10-6 Q16 x86_64 2020-05-08 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.0) 
Delegates (built-in): jng jpeg png x xml zlib

查看支持的文件格式

eric@eric-PC:~/Documents/work/linux-c/ImageMagick-7.0.10-6$ convert -list format
   Format  Mode  Description
-------------------------------------------------------------------------------
      3FR  r--   Hasselblad CFV/H3D39II
      3G2  r--   Media Container
      3GP  r--   Media Container
...

      ICO* rw+   Microsoft icon
     ICON* rw-   Microsoft icon
      IIQ  r--   Phase One Raw Image Format
     INFO  -w+   The image format and characteristics
   INLINE* rw+   Base64-encoded inline images
      IPL* rw+   IPL Image Sequence
   ISOBRL* -w-   ISO/TR 11548-1 format
  ISOBRL6* -w-   ISO/TR 11548-1 format 6dot
      JNG* rw-   JPEG Network Graphics
           See http://www.libpng.org/pub/mng/ for details about the JNG
           format.
      JNX* r--   Garmin tile format
      JPE* rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 1.5.2)
     JPEG* rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 1.5.2)
      JPG* rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 1.5.2)
      JPS* rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 1.5.2)
.......
 
      MOV  rw+   MPEG Video Stream
      MP4  rw+   MPEG-4 Video Stream
      MPC* rw+   Magick Persistent Cache image format
     MPEG  rw+   MPEG Video Stream
      MPG  rw+   MPEG Video Stream
      MRW  r--   Sony (Minolta) Raw Image File
      MSL* rw+   Magick Scripting Language
     MSVG  rw+   ImageMagick's own SVG internal renderer
      MTV* rw+   MTV Raytracing image format
      MVG* rw-   Magick Vector Graphics
      NEF  r--   Nikon Digital SLR Camera Raw Image File
      NRW  r--   Nikon Digital SLR Camera Raw Image File
     NULL* rw-   Constant image of uniform color
        O* rw+   Raw opacity samples
      ORF  r--   Olympus Digital Camera Raw Image File
      OTB* rw-   On-the-air bitmap
      PAL* rw-   16bit/pixel interleaved YUV
     PALM* rw+   Palm pixmap
      PAM* rw+   Common 2-dimensional bitmap format
    PANGO* ---   Pango Markup Language
  PATTERN* r--   Predefined pattern
 ........
      PNG* rw-   Portable Network Graphics (libpng 1.6.34)
           See http://www.libpng.org/ for details about the PNG format.
    PNG00* rw-   PNG inheriting bit-depth, color-type from original, if possible
    PNG24* rw-   opaque or binary transparent 24-bit RGB (zlib 1.2.11)
    PNG32* rw-   opaque or transparent 32-bit RGBA
    PNG48* rw-   opaque or binary transparent 48-bit RGB
    PNG64* rw-   opaque or transparent 64-bit RGBA
     PNG8* rw-   8-bit indexed with optional binary transparency
      PNM* rw+   Portable anymap
POCKETMOD  rw+   Pocketmod Personal Organizer
      PPM* rw+   Portable pixmap format (color)
       PS  rw+   PostScript
...........
      X3F  r--   Sigma Camera RAW Picture File
      XBM* rw-   X Windows system bitmap (black and white)
       XC* r--   Constant image uniform color
      XCF* r--   GIMP image
      XPM* rw-   X Windows system pixmap (color)
      XPS  r--   Microsoft XML Paper Specification
       XV* rw+   Khoros Visualization image
      XWD* rw-   X Windows system window dump (color)
        Y* rw+   Raw yellow samples
    YCbCr* rw+   Raw Y, Cb, and Cr samples
   YCbCrA* rw+   Raw Y, Cb, Cr, and alpha samples
      YUV* rw-   CCIR 601 4:1:1 or 4:2:2

* native blob support
r read support
w write support
+ support for multiple images

可以看到已经支持jpeg和png

 JPEG* rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 1.5.2)
 PNG* rw-   Portable Network Graphics (libpng 1.6.34)

七、转换图片格式
将文件QRcode.png转换成jpeg格式

eric@eric-PC:~/Documents/work/image$ ls
QRcode.png

转换命令:convert QRcode.png QRcode.jpeg

eric@eric-PC:~/Documents/work/image$ convert QRcode.png QRcode.jpeg
eric@eric-PC:~/Documents/work/image$ ls
QRcode.jpeg  QRcode.png

注意:
安装过程中,可能由于linux版本不同,可能会出现未找到对应的依赖项,而导致安装失败,安装对应的依赖项即可!!

--------------------------------------------------仅此记录---------------------------------------------------------

Logo

更多推荐