脚本:把图片裁成16等份,每份2%重叠

By admin, 4 十一月, 2015

(下面代码似乎有报错,不能运行了,可以下载附件的Perl版本)

儿子喜欢看地铁线路图,但是字太小会看坏眼睛,于是写了下面的脚本把地铁线路图裁成16等份,每份2%重叠,用16张A4纸彩色打印出来,然后用胶水粘在一起。脚本调用了ImageMagick的convert命令,最后一部分的偏移量要减去2%,我第一次的打的时候犯了这个错误,导致部分图片比例不对。

#!/bin/sh

# 4448x6290 => 16 * $WIDTHx$HEIGHT1

# A0 size is 2380x3368, A4 size is 595x842

 

WIDTH=4448

HEIGHT=6290

 

WIDTH1=$(($WIDTH * 0.245))

WIDTH2=$(($WIDTH * 0.49))

WIDTH3=$(($WIDTH * 0.735))

HEIGHT1=$(($HEIGHT * 0.245))

HEIGHT2=$(($HEIGHT * 0.49))

HEIGHT3=$(($HEIGHT * 0.735))

 

convert metro.jpg -crop 26.5%x26.5%+0+0 metro1.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH1+0 metro2.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH2+0 metro3.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH3+0 metro4.jpg

convert metro.jpg -crop 26.5%x26.5%+0+$HEIGHT1 metro5.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH1+$HEIGHT1 metro6.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH2+$HEIGHT1 metro7.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH3+$HEIGHT1 metro8.jpg

convert metro.jpg -crop 26.5%x26.5%+0+$HEIGHT2 metro9.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH1+$HEIGHT2 metro10.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH2+$HEIGHT2 metro11.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH3+$HEIGHT2 metro12.jpg

convert metro.jpg -crop 26.5%x26.5%+0+$HEIGHT3 metro13.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH1+$HEIGHT3 metro14.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH2+$HEIGHT3 metro15.jpg

convert metro.jpg -crop 26.5%x26.5%+$WIDTH3+$HEIGHT3 metro16.jpg

附件
metro.jpg (4.79 MB)
zoomimage.pl_.zip (465 字节)

评论

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
验证码
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
请输入"Drupal10"