我有以下代碼,當我在檔案上運行它時,我得到了轉換的幫助資訊
#!/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 [ "$1" == "" ];then
help
exit 1
fi
filename=$(basename -- "$1")
extension="${filename##*.}"
filename="${filename%.*}"
dirname="$(dirname $(readlink -e $1))"
sizes=( '1600x1200'
'1280x1024'
'440x247'
'1080x1920'
'1680x1050'
'1024x768'
'1366x768'
'3200x2000'
'3200x1800'
'2560x1600'
'3840x2160'
'720x1440'
'5120x2880'
'2560x1440'
'1280x800'
'360x720'
'1920x1200'
'1440x900'
'1920x1080'
)
if file "$1" | grep -qE 'image|bitmap'; then
mkdir $dirname/sizes
for size in ${sizes[@]};do
echo "converting to $size..."
convert "$1 -resize $size\> $dirname/sizes/$size.$extension"
done
else
echo "The $1 file is not a photo, please use a photo."
exit 1
fi
$ ./tools/convet_to_all_size 標志/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 Logo/parch_1000x_logo.png -resize 1920x1080\> /home/mmdbalkhi/w/parch/artwork/artwork/Logo/sizes/1920x1080.png
$ ls Logo/sizes
# 1920x1080.png
您認為問題出在哪里,我該如何解決?謝謝
uj5u.com熱心網友回復:
是因為轉換命令后的引號!感謝@zipzit
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/453166.html
標籤:重击 贝壳 图像魔术师 脚本 imagemagick 转换
上一篇:什么是參考命令?
下一篇:System.InvalidOperationException:'sessionnotcreated:此版本的ChromeDriver僅支持使用Selenium和C#的Chrome版本98
