我需要从一张中切出16张图像。
中的所有图片.tif format
。每个图像左上角的坐标包含在文本文件中。
就像是
100,200
300,400
...
我用了这个bash代码
IFS=','
while read x y; do
convert image.tif -crop 262x262+$x+$y image_%02d.tif;
done < coordinates
它给我395张错误坐标的图像。
我用请任何帮助。Ubuntu 14.04, Imagemagick 6.7.7
试试看-您%02d
的输出文件说明符中没有任何变量来表示。
#!/bin/bash
i=1
IFS=','
while read x y; do
name=$(printf "image%02d.tif" $i)
convert image.tif -crop 262x262+$x+$y "$name"
((i++))
done < coordinates
如果你并不真正需要的图像被称为不image01.tif
和image02.tif
,和image1.tif
,image2.tif
是好的,你可以简单地使用这个
#!/bin/bash
i=1
IFS=','
while read x y; do
convert image.tif -crop 262x262+$x+$y image$i.tif
((i++))
done < coordinates
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句