/usr/bin/tuxpaint-import is in tuxpaint 1:0.9.22-3.
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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | #!/bin/bash
# tuxpaint-import
# "Tux Paint Import"
# Import an arbitrary GIF, JPEG or PNG into Tux Paint
# (c) Copyright 2002-2009, by Bill Kendrick and others
# bill@newbreedsoftware.com
# http://www.newbreedsoftware.com/tuxpaint/
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# (See COPYING.txt)
# September 21, 2002 - November 4, 2009
SAVEDIR=$HOME/.tuxpaint
TMPDIR=$SAVEDIR
if [ $# -ne 0 ]; then
if [ $1 = "--help" ]; then
# --help, show usage:
echo
echo "tuxpaint-import"
echo
echo "Imports an arbitrary image (GIF, JPEG, PNG, etc. format)"
echo "into Tux Paint (see: tuxpaint(1)) so that it appears in the"
echo "'Open' dialog."
echo
echo "Usage: tuxpaint-import filename(s)"
echo " tuxpaint-import --help"
echo
exit
fi
fi
# Determine preferred savedir
# First, check /usr/local/etc/
x=`grep -m 1 "^savedir=" /usr/local/etc/tuxpaint/tuxpaint.conf`
if test $? = 0 ; then
SAVEDIR=`echo $x | cut -d = -f 2-99`
fi
# First, check /etc/
x=`grep -m 1 "^savedir=" /etc/tuxpaint/tuxpaint.conf`
if test $? = 0 ; then
SAVEDIR=`echo $x | cut -d = -f 2-99`
fi
# First, check $HOME
x=`grep -m 1 "^savedir=" $HOME/.tuxpaintrc`
if test $? = 0 ; then
SAVEDIR=`echo $x | cut -d = -f 2-99`
fi
echo "Using save directory: $SAVEDIR/saved"
# Make sure savedir exists!
if [ ! -d $SAVEDIR ]; then
echo "Creating $SAVEDIR"
mkdir -p $SAVEDIR
fi
# Make sure savedir/saved exists!
if [ ! -d $SAVEDIR/saved ]; then
echo "Creating $SAVEDIR/saved"
mkdir -p $SAVEDIR/saved
fi
# Make sure savedir thumbs directory exists!
if [ ! -d $SAVEDIR/saved/.thumbs ]; then
echo "Creating $SAVEDIR/saved/.thumbs"
mkdir -p $SAVEDIR/saved/.thumbs
fi
# Determine appropriate size for images, based on Tux Paint's current
# configuration
# First, assume 800x600 Tux Paint
window_width=800
window_height=600
# First, check /usr/local/etc/
x=`grep -m 1 "^windowsize=" /usr/local/etc/tuxpaint/tuxpaint.conf`
if test $? = 0 ; then
window_width=`echo $x | cut -d = -f 2 | cut -d x -f 1`
window_height=`echo $x | cut -d = -f 2 | cut -d x -f 2`
fi
# First, check /etc/
x=`grep -m 1 "^windowsize=" /etc/tuxpaint/tuxpaint.conf`
if test $? = 0 ; then
window_width=`echo $x | cut -d = -f 2 | cut -d x -f 1`
window_height=`echo $x | cut -d = -f 2 | cut -d x -f 2`
fi
# First, check $HOME
x=`grep -m 1 "^windowsize=" $HOME/.tuxpaintrc`
if test $? = 0 ; then
window_width=`echo $x | cut -d = -f 2 | cut -d x -f 1`
window_height=`echo $x | cut -d = -f 2 | cut -d x -f 2`
fi
# (Image width is window width minus 192,
# image height is window height minus 104)
width=`expr $window_width - 192`
height=`expr $window_height - 104`
echo "Using $width x $height images (for $window_width x $window_height Tux Paint"
if [ $# -eq 0 ]; then
# No arguments provided (sorry, you can't pipe into this script's stdin!)
echo
echo "Usage: tuxpaint-import filename(s)"
echo " tuxpaint-import --help"
exit
fi
# For each picture list...
for x in $(seq 1 $#)
do
i="${!x}"
if [ -e "$i" ]; then
# Determine a filename for it:
NEWFILENAME=`date "+%Y%m%d%H%M%S"`
echo "$i -> $SAVEDIR/saved/$NEWFILENAME.png"
# Convert and scale down, save as a temp file:
anytopnm "$i" | pnmscale -xysize $width $height > $TMPDIR/saved/$NEWFILENAME.ppm
# Place inside the correctly-sized canvas:
# FIXME: Center, instead of placing at upper right
ppmmake "#FFFFFF" $width $height \
| pnmpaste -replace $TMPDIR/saved/$NEWFILENAME.ppm 0 0 \
| pnmtopng > $SAVEDIR/saved/$NEWFILENAME.png
# Remove temp file:
rm $TMPDIR/saved/$NEWFILENAME.ppm
# Create thumbnail for 'Open' dialog:
pngtopnm $SAVEDIR/saved/$NEWFILENAME.png | pnmscale -xysize 92 56 \
| pnmtopng > $SAVEDIR/saved/.thumbs/$NEWFILENAME-t.png
else
# File wasn't there!
echo "$i - File not found"
fi
done
|