Scripts for non-power-of 2 textures
parent
23b3b01d92
commit
b88f1b716b
|
@ -0,0 +1,15 @@
|
|||
function nearest_pow2 {
|
||||
python -c "import math; print(2 ** int(math.ceil(math.log($1) / math.log(2.0))))"
|
||||
}
|
||||
|
||||
mkdir -p new
|
||||
|
||||
for file in $@ do
|
||||
size=$(identify $file | cut -d' ' -f 3)
|
||||
w=$(echo $size | cut -d'x' -f 1)
|
||||
h=$(echo $size | cut -d'x' -f 2)
|
||||
n_w=$(nearest_pow2 $w)
|
||||
n_h=$(nearest_pow2 $h)
|
||||
echo "$file: ${w}x${h} -> ${n_w}x${n_h}"
|
||||
convert $file -resize ${n_w}x${n_h}\! new/$file
|
||||
done
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
function check_npow2 {
|
||||
ans=`python -c "import math; l = math.log($1) / math.log(2.0); print(2**int(l) != $1)"`
|
||||
if [ "$ans" == "True" ]; then
|
||||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
for file in textures/*; do
|
||||
x_res=`identify $file | sed -E -n 's/.* ([0-9]+)x[0-9]+\+[0-9]+\+[0-9]+ .*/\1/p'`
|
||||
y_res=`identify $file | sed -E -n 's/.* [0-9]+x([0-9]+)\+[0-9]+\+[0-9]+ .*/\1/p'`
|
||||
npow_x=`check_npow2 $x_res`
|
||||
npow_y=`check_npow2 $y_res`
|
||||
if [ "$npow_x" == "1" -o "$npow_y" == "1" ]; then
|
||||
echo "`basename $file`: non-pow2 dimensions: ${x_res}x${y_res}"
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue