./nfo/linux/Alias|Wavefront Maya/projection.texture/maya.projection.scale.nfo
#!/bin/bash
# www.RLH.no 20110816
# Maya projection texture script for Linux.
# Credit to Dubravka, Ulf & Eric.
# This script will scale tif image sequence to fit perfectly
# in a video projection simulation from a Maya spotlight.
#
# 1. Set resolution of texture (128, 256, 512, 1024 or 2048).
#
# 2. Set filetype of original sequence (tif).
#
# 3. Run this script in the original sequence folder.
#
# 4. A new batch of images scaled for projection are created
# with the prefix of proj.[size].[original_filename]
#
# 5. Create a default spotlight in Maya.
#
# 6. Connect the projection sequence to the spotlights color
# channel as a file sequence.
#
# NOTE: Images without color seems to be output as grayscale,
# wich crashes Maya 2012 when connected to the spotlights
# color channel. Try to add "-type TrueColor" to the convert
# command. Will implement later :)
# ------------------------------------------------------------
# Set texture size:
# SIZE=128
# SIZE=256
SIZE=512
# SIZE=1024
# SIZE=2048
# Set file type:
EXT=tif
# ------------------------------------------------------------
for f in $( ls *.$EXT )
do
# Get image geometry:
WIDTH=$(identify -format '%w' $f)
HEIGHT=$(identify -format '%h' $f)
# Find hypotenus of image:
HYP=$(echo "scale=3; sqrt($WIDTH^2+$HEIGHT^2)" | bc)
# Round up decimals:
HYP=$(echo "$HYP" | awk '{printf "%.0f", $1}')
# Execute:
convert \
-background transparent \
-gravity center \
-extent "$HYP"x"$HYP" \
-scale "$SIZE"x"$SIZE" \
$f \
"proj.$SIZE.$f"
echo "proj.$SIZE.$f done..."
done