不工作 bash 脚本和 Imagemagic 转换但是命令是正确的
Do not work bash script and Imagemagic convert But command is correct
我有以下代码,当我 运行 将其写入文件时,我收到了转换程序的帮助消息
#!/bin/bash
help () {
printf "Parchos Arts convert script \n"
printf "Syntax: convert_to_all_size file [-h]\n"
printf "* file:\t\t\t\t A mandatory argument and must be a image\n"
printf "* -h: \t\t\t\t Show this message\n"
}
if [ "" == "" ];then
help
exit 1
fi
filename=$(basename -- "")
extension="${filename##*.}"
filename="${filename%.*}"
dirname="$(dirname $(readlink -e ))"
sizes=( '1600x1200'
'1280x1024'
'440x247'
'1080x1920'
'1680x1050'
'1024x768'
'1366x768'
'3200x2000'
'3200x1800'
'2560x1600'
'3840x2160'
'720x1440'
'5120x2880'
'2560x1440'
'1280x800'
'360x720'
'1920x1200'
'1440x900'
'1920x1080'
)
if file "" | grep -qE 'image|bitmap'; then
mkdir $dirname/sizes
for size in ${sizes[@]};do
echo "converting to $size..."
convert " -resize $size\> $dirname/sizes/$size.$extension"
done
else
echo "The file is not a photo, please use a photo."
exit 1
fi
$ ./tools/convet_to_all_size Logo/parch_1000x_logo.png
- 输出:
...
converting to 1920x1080...
convert Logo/parch_1000x_logo.png -resize 1920x1080\> /home/mmdbalkhi/w/parch/artwork/artwork/Logo/sizes/1920x1080.png
然后我在包含 convert 命令的行前面写了一个 echo,我手动执行它,一切正常!
$ convert Logo/parch_1000x_logo.png -resize 1920x1080\> /home/mmdbalkhi/w/parch/artwork/artwork/Logo/sizes/1920x1080.png
$ ls Logo/sizes
# 1920x1080.png
您认为问题出在哪里,我该如何解决?谢谢
是因为convert命令后面的引号!感谢@zipzit
我有以下代码,当我 运行 将其写入文件时,我收到了转换程序的帮助消息
#!/bin/bash
help () {
printf "Parchos Arts convert script \n"
printf "Syntax: convert_to_all_size file [-h]\n"
printf "* file:\t\t\t\t A mandatory argument and must be a image\n"
printf "* -h: \t\t\t\t Show this message\n"
}
if [ "" == "" ];then
help
exit 1
fi
filename=$(basename -- "")
extension="${filename##*.}"
filename="${filename%.*}"
dirname="$(dirname $(readlink -e ))"
sizes=( '1600x1200'
'1280x1024'
'440x247'
'1080x1920'
'1680x1050'
'1024x768'
'1366x768'
'3200x2000'
'3200x1800'
'2560x1600'
'3840x2160'
'720x1440'
'5120x2880'
'2560x1440'
'1280x800'
'360x720'
'1920x1200'
'1440x900'
'1920x1080'
)
if file "" | grep -qE 'image|bitmap'; then
mkdir $dirname/sizes
for size in ${sizes[@]};do
echo "converting to $size..."
convert " -resize $size\> $dirname/sizes/$size.$extension"
done
else
echo "The file is not a photo, please use a photo."
exit 1
fi
$ ./tools/convet_to_all_size Logo/parch_1000x_logo.png
- 输出:
...
converting to 1920x1080...
convert Logo/parch_1000x_logo.png -resize 1920x1080\> /home/mmdbalkhi/w/parch/artwork/artwork/Logo/sizes/1920x1080.png
然后我在包含 convert 命令的行前面写了一个 echo,我手动执行它,一切正常!
$ convert Logo/parch_1000x_logo.png -resize 1920x1080\> /home/mmdbalkhi/w/parch/artwork/artwork/Logo/sizes/1920x1080.png
$ ls Logo/sizes
# 1920x1080.png
您认为问题出在哪里,我该如何解决?谢谢
是因为convert命令后面的引号!感谢@zipzit