码迷,mamicode.com
首页 > 系统相关 > 详细

linux图片处理工具GraphicsMagick安装使用

时间:2016-11-04 17:59:44      阅读:562      评论:0      收藏:0      [点我收藏+]

标签: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图片处理工具GraphicsMagick安装使用

标签:linux 图片处理

原文地址:http://linuxgfc.blog.51cto.com/6117252/1869215

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!