我有一个如下的Bash shell脚本。
#!/bin/bash
SIZES=("512" "1024" "2048")
for i in ${!SIZES[*]}
do
SIZE=${SIZES[$i]}
echo $SIZE
# first, resize original image
convert -resize $SIZE"x"$SIZE! chernarus2048.jpg chernarus$SIZE"x"$SIZE.jpg
mkdir tiles$SIZE
# slice resized image into 256x256 tiles
convert -crop 256x256 chernarus$SIZE"x"$SIZE.jpg tiles$SIZE/tile%04d.jpg
rm chernarus$SIZE"x"$SIZE.jpg
done
但是当我使用以下命令在命令行中运行时
sh generate_tiles.sh chernarus2048.jpg
我遇到了一个错误convert: 命令未找到
我正在使用OS X Yosemite 10.10.2。图像保存在与shell脚本相同的文件夹中。请帮帮我。
convert
不在你的路径中。你能正常运行它吗?which convert
告诉你什么? - Tom Fenech$1
。 - Barmarsh
运行 bash 脚本。尽管 OSX 的sh
实际上是 bash,但它的行为不同,并且某些 bash 功能被禁用。 - geirha