selphy_print/pano-split.sh
Solomon Peachy 03ca5ce596 mitsud90: Theoretically we support continuous panoramas now
This required substantial rework of the "common" rgb8 pano split code to
add blending support (modeled after the DNP stuff) along with MANY
bugfixes.

The Sinfonia pano code (used by the EK8810 and EK69xx) also needed
to be tweaked, but that isn't expected to work on real printers yet due to
unknown control protocol bits.
2024-01-07 12:24:10 -05:00

202 lines
4.5 KiB
Bash
Executable file

#!/bin/bash
###########
# Splits a panorama image into overlapping panels of the correct size.
#
# Note that this is _very_ preliminary, doing the fading/overlapping in a
# very naive linear manner.
#
# Also note that this script will probably go away as its functionality
# is moved into selphy_print &| gutenprint
#
infile="$1"
outfile="$2"
model="$3"
printsize="$4"
if [ -z "$5" ] ; then
dpi=300
else
dpi="$5"
fi
# D90
case "${model}" in
kodak-6900|kodak-6950)
pad=36
overlap=600
if [ "${printsize}" eq "6x20" ] ; then
cols=1844
inrows=6036
drows=2436
elif [ "${printsize}" eq "6x18" ] ; then
cols=1844
inrows=5436
drows=2436
elif [ "${printsize}" eq "6x14" ] ; then
cols=1844
inrows=4236
drows=2436
elif [ "${printsize}" eq "6x12" ] ; then
cols=1844
inrows=3636
drows=2436
elif [ "${printsize}" eq "5x20" ] ; then
cols=1548
inrows=6036
overlap=136 # 100 + 36
drows=2136
elif [ "${printsize}" eq "5x15" ] ; then
cols=1548
inrows=4536
drows=2136
elif [ "${printsize}" eq "5x10" ] ; then
cols=1548
inrows=3036
drows=2136
else
echo "EK69xx supports 6x20, 6x18, 6x14, 6x12, 5x20, 5x15, and 5x10 only";
fi
;;
kodak-8810)
cols=2464
pad=24
overlap=360 ### XXX probably wrong?
if [ "${printsize}" eq "8x14" ] ; then
inrows=4224
drows=3024 # or 3624
elif [ "${printsize}" eq "8x16" ] ; then
inrows=4824
drows=3024 # or 3624
elif [ "${printsize}" eq "8x20" ] ; then
inrows=6024
drows=3024 # or 3624?
elif [ "${printsize}" eq "8x24" ] ; then
inrows=7224
drows=3024 # or 3624, with overlap=180
elif [ "${printsize}" eq "8x32" ] ; then
inrows=9624
drows=3624
elif [ "${printsize}" eq "8x36" ] ; then
overlap=180 # XXX probably wrong?
inrows=10824
drows=3624
else
echo "EK8810 supports 8x14, 8x16, 8x20, 8x32, and 8x36 only";
fi
;;
mitsubishi-d90dw)
cols=1852
pad=28
drows=2428
overlap=600
if [ "${printsize}" eq "6x20" ] ; then
inrows=6028
elif [ "${printsize}" eq "6x14" ] ; then
inrows=4228
else
echo "D90 supports 6x20 and 6x14 only"
exit 1
fi
;;
dnp-ds620)
cols=1844
drows=2436
pad=36
overlap=600
if [ "${printsize}" eq "6x20" ] ; then
inrows=6036
elif [ "${printsize}" eq "6x14" ] ; then
inrows=4236
else
echo "DS620 supportx 6x20 and 6x14 only"
exit 1
fi
;;
dnp-ds820)
overlap=600
pad=36
cols=2448
if [ "${printsize}" eq "8x18" ] ; then
drows=3036
inrows=5436
elif [ "${printsize}" eq "8x26" ] ; then
drows=3036
inrows=7836
elif [ "${printsize}" eq "8x22" ] ; then
drows=3636
inrows=6636
elif [ "${printsize}" eq "8x32" ] ; then
drows=3636
inrows=9636
else
echo "DS820 supportx 8x18, 8x26, 8x22, and 8x32 only"
fi
;;
*)
echo "Unsupported model!"
exit 1
;;
esac
# For 600dpi, double everything!
if [ ${dpi} -gt 300 ] ; then
overlap=`expr ${overlap} * 2`
cols=`expr ${cols} * 2`
drows=`expr ${drows} * 2`
inrows=`expr ${inrows} * 2`
pad=`expr ${pad} * 2`
fi
# Calculate page count XXX is this sane?
pages=`expr ${drows} - ${overlap}`
pages=`expr ${inrows} / ${pages}`
# Create gradients
fadeinname=fade_in_${cols}.pgm
fadeoutname=fade_out_${cols}.pgm
gm convert -size ${cols}x${overlap} gradient:white-black ${fadeinname}
gm convert -size ${cols}x${overlap} gradient:black-white ${fadeoutname}
# Subtract off padding from rows.
drows=`expr ${drows} - ${pad} - ${pad}`
# Generate panels
src_offset=`expr $pad / 2`
panels=''
for panel in `seq 1 ${pages}` ; do
echo "generating $panel / $pages"
panelname=panel_${panel}.ppm
panels="${panels} ${panelname}"
# Generate panel
rows=`expr ${drows} + ${pad} + ${pad}`
gm convert ${infile} -crop ${cols}x${rows}+0+${src_offset} ${panelname}
## XXX panel needs to have WHITE margin of ${pad rows} on either end
# perhaps add to fades?
# need a tail too.
# Increment offset
src_offset=`expr ${src_offset} + ${drows}`;
src_offset=`expr ${src_offset} - ${overlap}`;
# All but last panel fades out
if [ ${panel} -lt ${pages} ] ; then
gm composite -compose screen -gravity south ${fadeoutname} ${panelname} ${panelname}
fi
# All but first panel fades in
if [ ${panel} -gt 1 ] ; then
gm composite -compose screen -gravity north ${fadeinname} ${panelname} ${panelname}
fi
done
# Clean up templates
rm ${fadeinname} ${fadeoutname}
## Create PDF
gm convert -density ${dpi}x${dpi} ${panels} ${outfile}