第一次使用code标签 可能排版方面还不熟悉
看的费劲还多多见谅
这里主要是针对imagemagick 的text usage做的一个TestCase
实际使用的工程正在制作中
过程中我也尽力会搜集一些需要注意的问题
放到这里 希望得到大家的指正 同大家共同进步
@Test
public void testScale() throws Exception {
String convert = "C:/Program Files/ImageMagick-6.4.3-Q8/convert.exe";
//支持\n等转义符
String label = "SNOWIING\n中文支持需要编码下待解决\npowered by snowing";
String out = "d:/snowing.jpg";
//generate image
Map pvs = new HashMap();
pvs.put("background", "lightblue"); //背景色
pvs.put("fill", "#00ccff"); //字体填充色
pvs.put("font", "SimSun"); //字体
pvs.put("size", "800x100"); //生成图片的尺寸
pvs.put("pointsize", "24"); //字体大小?
pvs.put("gravity", "center"); //对齐方式?
pvs.put("strokewidth", "1"); //边框宽度
pvs.put("stroke", "blue"); //边框颜色
pvs.put("undercolor", "red"); //文字底色
//pvs.put("kerning", "1"); //文字(字母)间距
//pvs.put("interword-spacing", "1"); //单词间距
ArrayList<String> command = new ArrayList<String>();
command.add(convert);
for(Iterator it = pvs.keySet().iterator();it.hasNext();){
Object _key = it.next();
Object _val = pvs.get(_key);
command.add("-"+String.valueOf(_key));
command.add(String.valueOf(_val));
}
command.add("label:"+label);
command.add(out);
Exec.exec((String[])command.toArray(new String[1]));
//add some effect
Map epvs = new HashMap();
epvs.put("charcoal", "1"); //炭笔
epvs.put("colorize", "250"); //着色 可以指定三种颜色 red/green/blue
//epvs.put("implode", "4"); //内爆效果
//epvs.put("solarize", "42"); //曝光,模拟胶片曝光
//epvs.put("spread", "5"); //随机移动,参数是位移大小
epvs.put("bordercolor", "blue");//增加有色边
epvs.put("border", "25x5");
epvs.put("raise", "25"); //加亮或变暗图片边缘,以增强3D效果
epvs.put("mattecolor", "#ffccdd"); //在图片周围增加装饰性框架
epvs.put("frame", "25x25");
epvs.put("frame", "25x25+0+25");//在图片边缘增加升、降斜角
epvs.put("frame", "25x25+25+0");
command = new ArrayList<String>();
command.add(convert);
for(Iterator it = epvs.keySet().iterator();it.hasNext();){
Object _key = it.next();
Object _val = epvs.get(_key);
command.add("-"+String.valueOf(_key));
command.add(String.valueOf(_val));
}
command.add(out);
command.add(out);
Exec.exec((String[])command.toArray(new String[1]));
}