标签:linux 图片处理
安装依赖包:
yum install libpng libjpeg freetype libpng-devel libjpeg-devel
官网下载GraphicsMagick包
官网地址:http://www.graphicsmagick.org/
解压编译安装:
tar xf GraphicsMagick-1.3.25.tar.gz
./configure --prefix=/usr/local/graphicsmagick-1.3.25 --enable-shared --enable-lzw --without-perl --with-modules
make && make install
附图片批量处理脚本:
#!/bin/bash IFS=`echo -en "\n\b"`; echo $IFS function geneThumb() { for file in `ls $1` do echo $file image="${1}/${file}" thumb="${1}/Thumb_${file}" ext_name=${file##*.} image_basename=`basename $image` if [ -d ${image} ] then geneThumb ${image} elif ( [ ${image_basename:0:5} != "Thumb" ]) && ( [ ! -f ${thumb} ] ) && ( [ $ext_name = ‘jpg‘ -o $ext_name = ‘gif‘ -o $ext_name = ‘png‘ -o $ext_name = ‘bmp‘ ] ) then echo $thumb if [ $ext_name = ‘png‘ -o $ext_name = ‘bmp‘ ] then gm convert "$image" -thumbnail 128x128 -colors 256 "$thumb" else gm convert "$image" -thumbnail 128x128 -quality 85 "$thumb" fi else echo "already exists" fi done } geneThumb $1
本文出自 “linuxgfc” 博客,请务必保留此出处http://linuxgfc.blog.51cto.com/6117252/1869215
标签:linux 图片处理
原文地址:http://linuxgfc.blog.51cto.com/6117252/1869215