/usr/bin/label3d is in raster3d 3.0-3-2+b1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | #!/bin/sh
#
# Raster3D labeling script label3d V2.7a
# ======================================
#
# Ethan A Merritt April 2002
#
# Usage
# label3d -tiff [outfile.tiff] < inputfile.r3d > file_with_labels.tiff
# label3d [-png [outfile.png]] < inputfile.r3d > file_with_labels.png
#
# Environmental variables
# FONTSCALE controls mapping of nominal font size to height in pixels
# TMPDIR controls where scratch files will be written
#
# Changes
# - 2.6d is a fairly major change; the older version is label3d_old
# - output to stdout, rather than always to a file ./label3d.tiff
# - temporary files are placed in $TMPDIR if defined, else /usr//tmp
# - together these changes mean you can run label3d from a directory
# for which you do not have write access
# - add -png option (tiff is still the default)
# - 2.6g default to png
#
# Requirements
# - Requires ghostscript and ImageMagick.
# ImageMagick behavior is version-dependent (fooey on them!)
# so you may have to edit this script if you update ImageMagick
# currently known to work for V2.4.9 and V5.3.2
# - Depending on what size images you typically produce,
# you might want to change the default FONTSCALE definition below
#
if [ ! "$FONTSCALE" ]; then FONTSCALE=3.0; fi
#
# Construct base name for scratch files
#
#echo "DEBUG TMPDIR is $TMPDIR" 1>&2
if [ "$TMPDIR" ]; then
tmp=$TMPDIR/$$
else
tmp=/usr/tmp/$$
fi
#echo "DEBUG scratch files to $tmp" 1>&2
#
# Parse command line options (currently only -png)
#
unset outfile
unset img
previous=
for option in $*
do
if [ "$option" = "-png" ]; then img=png;
elif [ "$option" = "-tiff" ]; then img=tiff;
else
if [ "$previous" = "-tiff" ] || [ "$previous" = "-png" ] ; then
if [ `echo "$option" | sed -e 's/\(.\).*/\1/'` != "-" ]; then
outfile="$option"
fi
else
echo "label3d version 2.7a"
echo "unrecognized option: $option" 1>&2
echo "Usage: label3d [-tiff [out.tiff]] [-png [out.png]] < in.r3d > outfile"
exit 1
fi
fi
previous="$option"
done
if [ "$img" != "tiff" ]; then
img=png
fi
#DEBUG
# if [ "$outfile" ]; then
# echo "DEBUG label3d: $img output to $outfile" 1>&2
# else
# echo "DEBUG label3d: $img output to stdout" 1>&2
# fi
#DEBUG
#
# Buffer input to scratch file
#
cat > ${tmp}_label3d.tmp
#
#
rm -f ${tmp}_render.${img} ${tmp}_label3d.ps
render -labels ${tmp}_label3d.ps -fontscale $FONTSCALE -${img} ${tmp}_render.${img} < ${tmp}_label3d.tmp
if [ ! -e ${tmp}_render.${img} ]; then
echo "label3d: could not find output ${tmp}_render.${img} from render" 1>&2
rm -f ${tmp}_*
exit 1
fi
if [ ! -e ${tmp}_label3d.ps ]; then
cat ${tmp}_render.${img}
echo "label3d: no labels found" 1>&2
rm -f ${tmp}_*
exit 0
fi
#
IMAGESIZE=`identify ${tmp}_render.${img} | sed -e 's/.* \([0-9]*x[0-9]*\).*/\1/'`
if ( gs -sDEVICE=png16m -dNOPAUSE -q -sOutputFile=${tmp}_label3d.png \
-g$IMAGESIZE ${tmp}_label3d.ps -c quit )
then
echo "label3d: labels written to ${tmp}_label3d.png" 1>&2
else
echo "label3d: GhostScript error" 1>&2
rm -f ${tmp}_*
exit 1
fi
#
# Insure that the labels are on a transparent background
# NB: ImageMagick version 6+ syntax!
#
convert ${tmp}_label3d.png -fill none -draw "matte 0,0 replace" ${tmp}_label3d.miff
#
# This works with ImageMagick 4.2.9 and many (most?) other older versions
#
if ( combine -compose over \
${tmp}_render.${img} ${tmp}_label3d.miff ${tmp}_label3d.${img} 2>/dev/null)
then
echo "label3d: using combine" 1>&2
#
# This works with ImageMagick 5.3.2
#
else
echo "label3d: using composite instead of combine" 1>&2
composite -compose over ${tmp}_label3d.miff ${tmp}_render.${img} ${tmp}_label3d.${img}
fi
#
# output to explicit file or to stdout
#
if [ "$outfile" ]; then
mv ${tmp}_label3d.${img} $outfile
else
cat ${tmp}_label3d.${img}
fi
#
# Cleanup
#
# echo "label3d: cleanup" 1>&2
rm -f ${tmp}_label3d.ps ${tmp}_label3d.${img}
rm -f ${tmp}_label3d.tmp ${tmp}_label3d.png ${tmp}_label3d.miff ${tmp}_render.${img}
exit 0
|