如何使用ImageMagick切割选择性图像

时间:2017-01-30 12:31:02

标签: imagemagick

我想截取专门针对移动设备的截图图片。并按顺序将它们捆绑成pdf。

#!/bin/sh

desktop_path=./screenshots/desktop/
mobile_path=./screenshots/mobile/
pdf_path=./pdf/

convert ${desktop_path}screenshot-1.png ${desktop_path}screenshot-2.png ${desktop_path}screenshot-3.png ${desktop_path}screenshot-4.png ${desktop_path}screenshot-5.png ${desktop_path}screenshot-6.png ${desktop_path}screenshot-7.png ${desktop_path}screenshot-8.png ${desktop_path}screenshot-9.png ${desktop_path}screenshot-10.png ${desktop_path}screenshot-11.png ${desktop_path}screenshot-12.png ${desktop_path}screenshot-13.png -chop 0x0 ${mobile_path}screenshot-1.png ${mobile_path}screenshot-2.png ${mobile_path}screenshot-3.png ${mobile_path}screenshot-4.png ${mobile_path}screenshot-5.png ${mobile_path}screenshot-6.png ${mobile_path}screenshot-7.png ${mobile_path}screenshot-8.png ${mobile_path}screenshot-9.png ${mobile_path}screenshot-10.png ${mobile_path}screenshot-11.png ${mobile_path}screenshot-12.png ${mobile_path}screenshot-13.png ${mobile_path}screenshot-14.png -chop 0x43 ${pdf_path}packets-temp.pdf

我面临的问题是,尽管我已经为桌面定义了-chop 0x0,但它没有跳过桌面版本,而是像桌面上那样砍掉了43px的桌面版本。移动。

2 个答案:

答案 0 :(得分:1)

如果您不希望将印章应用于某些图像,请将您想要的印章放在括号中,然后将其切碎:

convert NoChop.png \( ChopMe.png ChopMeToo.png -chop 10x10 \) ... 

或者,首先加载你想要切碎的那些,切碎它们,然后添加你不想切碎的那些:

convert ChopMe.png ChopMeToo.png -chop 10x10 NoChop.png ...

答案 1 :(得分:0)

#!/bin/sh

desktop_path=./screenshots/desktop/
mobile_path=./screenshots/mobile/
mobile_cropped_path=./screenshots/mobile/cropped/
pdf_path=./pdf/

mogrify -path ${mobile_cropped_path} -chop 0x43 ${mobile_path}*.png 

convert ${desktop_path}*.png ${mobile_cropped_path}*.png ${pdf_path}packets-temp.pdf