
이미지 크기를 백분율 값으로 조정하는 스크립트가 있습니다.
#!/bin/bash
percent=$1
echo $percent
for img in `find *.png`;
do
echo Processing file $img
width=$( mdls $img | grep kMDItemPixelWidth | tail -n1 | cut -d= -f2 )
height=$( mdls $img | grep kMDItemPixelHeight | tail -n1 | cut -d= -f2 )
newWidth=$((width*percent))
newHeight=$((height*percent))
echo $newWidth $newHeight
sips -z $newWidth $newHeight $img
done
내 bash는 쉼표를 소수 구분 기호로 허용하도록 구성되었습니다.
그래서 내가 타이핑하는 이유
rescale 0,3019
이미지 크기를 해당 값의 30.19%로 조정하려고 합니다.
문제는 그 줄이
echo $newWidth $newHeight
3019를 곱한 값을 보여줍니다. 이상하게도 첫 번째 에코는
echo $percent
0,3019(올바른 값)가 표시됩니다.
내가 무엇을 놓치고 있나요?
답변1
헤드라인에: bash는 정수만 곱할 수 있습니다.