服务器搭建:3.1、openresty图片压缩之GraphicsMagick
2019獨角獸企業重金招聘Python工程師標準>>>
服務器環境 CentOS6
版本
openresty?? 1.7.10.2?? 下載地址:https://openresty.org/download/ngx_openresty-1.7.10.2.tar.gz
更多Openresty版本請參見:http://openresty.org/cn/download.html
GraphicsMagick-1.3.19 下載地址:http://jaist.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.19/GraphicsMagick-1.3.19.tar.gz
更多GraphicsMagick版本請參見:https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/
安裝GraphicsMagick需要有3個組件支持,當然這是基于我當前系統的版本而言,他們分別是:
?1、libtool-ltdl-devel 這里用的云安裝
?yum install libtool-ltdl libtool-ltdl-devel
2、libpng
http://nchc.dl.sourceforge.net/project/libpng/libpng16/1.6.20/libpng-1.6.20.tar.gz
建議? yum安裝:
#?yum?install?libpng #?yum?install?libpng-devel?http://nchc.dl.sourceforge.net/project/libjpeg/libjpeg/6b/jpegsrc.v6b.tar.gz
只有安裝了以上3個組件,才會讓GraphicsMagick能壓縮.jpeg和 .png文件,同時才能令它編譯成功。
編譯GraphicsMagick
1、解壓并進入安裝目錄,執行編譯
./configure? '--prefix=/usr/local/GraphicsMagick-1.3.19' '--exec-prefix=/usr/local/GraphicsMagick-1.3.19' '--bindir=/usr/local/GraphicsMagick-1.3.19/bin' '--sbindir=/usr/local/GraphicsMagick-1.3.19/sbin' '--sysconfdir=/usr/local/GraphicsMagick-1.3.19/etc' '--datadir=/usr/local/GraphicsMagick-1.3.19/share' '--includedir=/usr/local/GraphicsMagick-1.3.19/include' '--libdir=/usr/local/GraphicsMagick-1.3.19/lib' '--libexecdir=/usr/local/GraphicsMagick-1.3.19/libexec' '--localstatedir=/usr/local/GraphicsMagick-1.3.19/var' '--sharedstatedir=/usr/local/GraphicsMagick-1.3.19/share/com' '--mandir=/usr/local/GraphicsMagick-1.3.19/share/man' '--infodir=/usr/local/GraphicsMagick-1.3.19/share/info' '--enable-libtool-verbose' '--with-included-ltdl' '--enable-shared' '--disable-static' '--with-modules' '--with-frozenpaths' '--without-perl' '--without-magick-plus-plus' '--with-quantum-depth=8' --enable-symbol-prefix
如果你的版本和安裝路徑和我的不同,直接去替換內容就行:/usr/local/GraphicsMagick-1.3.19
編碼如果沒有出現異常,在最后的輸出中 肯定會有以下這部分,請注意紅色標識位置必須為yes否則后續無法壓縮
Option??????????? Configure option????????????? Configured value
-----------------------------------------------------------------
Shared libraries? --enable-shared=yes?????????? yes
Static libraries? --enable-static=no??????????? no
GNU ld??????????? --with-gnu-ld=yes???????????? yes
Quantum depth???? --with-quantum-depth=8??????? 8
Modules?????????? --with-modules=yes??????????? yes
Delegate Configuration:
BZLIB???????????? --with-bzlib=yes????????????? no
DPS?????????????? --with-dps=yes??????????????? no
FlashPIX????????? --with-fpx=no???????????????? no
FreeType 2.0????? --with-ttf=yes??????????????? no
Ghostscript?????? None????????????????????????? /usr/bin/gs (9.07)
Ghostscript fonts --with-gs-font-dir=default??? /usr/share/fonts/default/Type1/
Ghostscript lib?? --with-gslib=no?????????????? no
JBIG????????????? --with-jbig=yes?????????????? no
WEBP????????????? --with-webp=yes?????????????? no
JPEG v1?????????? --with-jpeg=yes?????????????? yes
JPEG-2000???????? --with-jp2=yes??????????????? no
LCMS v1?????????? --with-lcms=yes?????????????? no
LCMS v2?????????? --with-lcms2=yes????????????? no
LZMA????????????? --with-lzma=yes?????????????? no
Magick++????????? --with-magick-plus-plus=no??? no
PERL????????????? --with-perl=no??????????????? no
PNG?????????????? --with-png=yes??????????????? yes (-lpng16)
TIFF????????????? --with-tiff=yes?????????????? no
TRIO????????????? --with-trio=yes?????????????? no
Windows fonts???? --with-windows-font-dir=????? none
WMF?????????????? --with-wmf=yes??????????????? no
X11?????????????? --with-x=???????????????????? no
XML?????????????? --with-xml=yes??????????????? no
ZLIB????????????? --with-zlib=yes?????????????? yes
接下來就是安裝的2步操作
# make?
# make install?
配置環境變量(必要)
vi /etc/profile
在最后位置插入如下配置
export GM_HOME=/usr/local/GraphicsMagick-1.3.19
export PATH=$GM_HOME/bin:$GM_HOME/lib:$PATH
保存退出。
并執行如下命令使它立即生產:
# ldconfig
#source /etc/profile
完成后可以查看GraphicsMagick是否支持了相應圖片格式的處理:
#? gm convert -list formats?
執行后輸出結果,請注意查找到以下這些內容(可能不是放在一起的,請自行比對):
?GIF P? rw+? CompuServe graphics interchange format (version 89a)
?JPEG P? rw-? Joint Photographic Experts Group JFIF format (IJG JPEG 62)
?JPG P? rw-? Joint Photographic Experts Group JFIF format (IJG JPEG 62)
? PNG P? rw-? Portable Network Graphics (libpng 1.2.49, zlib 1.2.3)
??????????? See http://www.libpng.org/ for information on PNG..
??? PNG00 P? rw-? PNG that inherits type and depth from original (libpng 1.2.49, zlib 1.2.3)
??? PNG24 P? rw-? 24-bit RGB PNG, opaque only (libpng 1.2.49, zlib 1.2.3)
??? PNG32 P? rw-? 32-bit RGBA PNG, semitransparency OK (libpng 1.2.49, zlib 1.2.3)
??? PNG48 P? rw-? opaque or binary transparent 48-bit RGB (libpng 1.2.49, zlib 1.2.3)
??? PNG64 P? rw-? opaque or transparent 64-bit RGBA (libpng 1.2.49, zlib 1.2.3)
????PNG8 P? rw-? 8-bit indexed PNG, binary transparency only (libpng 1.2.49, zlib 1.2.3)????
會發現,就是圖片格式名,這說明他支持這類圖片的壓縮了。?
?
?到此GraphicsMagick就安裝完成后,后續與nginx以及lua配合請點擊這里: 3.2、openresty圖片壓縮之 lua調用GraphicsMagick
轉載于:https://my.oschina.net/u/2553994/blog/668951
總結
以上是生活随笔為你收集整理的服务器搭建:3.1、openresty图片压缩之GraphicsMagick的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: easyui validatebox验证
- 下一篇: mysql初步调试