使用方法:解压后sh imageconvert.sh 输入路径 输出路径 定宽宽度x定高高度
定高高度和定宽宽度按照原图的形状,设置值较小一端,另一端按比例缩放
首先要安装ImageMagic
3.0新增加水印
使用色域空间的ICC在附件中。
代码如下:
#/bin/bash
## author:wangjianwu
#version 0.1
if [ ! -x "${1}" ] || [ ! -x "${2}" ] || [ -z ${3} ] || [ -z ${4} ]; then
echo "maybe file not found or command error!"
echo "help:command inputdir outputdir size density [w|h|wh]"
exit -1
fi
CONVERT="convert"
export CMYK_ICC=CoatedFOGRA39.icc
export RGB_ICC=AdobeRGB1998.icc
ext="jpg"
bwidth=`echo "${3}"|awk -F 'x' '{print $1}'`
bheight=`echo "${3}"|awk -F 'x' '{print $2}'`
inpath=${1}
pathPosition=${#inpath}
echo "${pathPosition}"
find ${1} -type f | while read line
do
fext=${line##*.}
if [ "$ext" != "$fext" ]
then
continue
fi
imageFilePath=`echo ${line} | cut -c ${pathPosition}-${#line}`
imageOutputPath="${2}${imageFilePath}"
op="${2}"
#ps=`echo $str|tr '\/' ' '|tr -s ' '`
ps=`echo ${imageFilePath} | sed 's/\// /g'`
endps=`echo ${imageFilePath} | awk -F "\/" '{print $NF}'`
for keystr in `echo ${imageFilePath} | sed 's/\// /g'`
do
op="${op}/${keystr}"
if [ "$keystr" = "$endps" ]
then
continue
fi
if [ ! -x ${op} ]
then
mkdir ${op}
fi
done
#get width and heigth
width=`identify -format "%w" ${line}`
height=`identify -format "%h" ${line}`
#echo "${width}========${height}"
if [ ! -z ${5} ] && [ "${5}" == "w" ]
then
echo "xxxX"
bsize="${bwidth}x${height}"
elif [ ! -z ${5} ] && [ "${5}" == "h" ]
then
echo "yy"
bsize="${width}x${bheight}"
elif [ ! -z ${5} ] && [ "${5}" == "wh" ]
then
echo "xxy"
bsize="${bwidth}x${bheight}"
elif [ $width -gt $height ]
then
# echo "width>height"
bsize="${width}x${bheight}"
elif [ $width -lt $height ]
then
# echo "width<height"
bsize="${bwidth}x${height}"
else
if [ $bwidth -gt $bheight ]
then
bsize="${bwidth}x${bwidth}"
else
bsize="${bheight}x${bheight}"
fi
fi
convertCommand="${CONVERT} -density ${4} -units PixelsPerInch ${line} -resize ${bsize} -profile ${CMYK_ICC} -profile ${RGB_ICC} ${imageOutputPath}"
echo ${convertCommand}
${convertCommand}
echo "${width}x${height}"
done
分享到:
相关推荐
描述怎样将pdf文件的颜色模式从RGB转CMYK
RGB图片转CMYK处理,使用ICC文件,采用原生方法
用Java语言实现RGB与CMYK色彩空间的转换-Java language RGB and CMYK color space conversion
小工具 可以简单的转换一下cmyk 到 rgb
rgb cmyk
RGB转CMYK软件,大家方便了!希望对大家有帮助,赶快来下载呀!
提供RGB与CMYK值之间的相互转换,文件很小,方便转换。
Converts cmyk color scale (tiff image) to rgb.
java 实现cmyk转rgb,用ImageMagick转换需要额外安装软件,这个不需要安装额外软件
.net下的RGB图片转CMYK处理
Adobe的RGB与CMYK的色彩转换公式,适用于要求按照图示四色出图的朋友们。
RGB转CMYK小工具 mapgis应用
PANTONE色值互相转换RGB与CMYK,是设计师必备利器,用来查看PANTONE色值,尤其用于织物色值查询。 2010-10月补充编辑:看到这个小软件能帮助这么多朋友非常高兴。关于使用方面做点补充说明,打开后可以在右下角图标...
图像中rgb值和cmyk值转换,用于颜色空间变换。
iOS中将CMYK的颜色格式转换成RGB的方法封装
jar 博文链接:https://qiufengzi1987.iteye.com/blog/1751941
Java实现RGB与CMYK色彩空间的转换
还在为ie无法显示cmyk格式的jpg图片烦恼吗。本代码完全完整cmyk转rgb 严格经过测试
NULL 博文链接:https://1136051009.iteye.com/blog/1894239