"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "scripts/opt-gif.in" between
littleutils-1.2.3.tar.lz and littleutils-1.2.4.tar.lz

About: littleutils are a collection of small and simple utilities (rename files, search for duplicate files, ...).

opt-gif.in  (littleutils-1.2.3.tar.lz):opt-gif.in  (littleutils-1.2.4.tar.lz)
#! PROGDASH #! PROGBASH
# vim: set filetype=sh: # vim: set filetype=bash:
# opt-gif: Recompresses .gif files # opt-gif: Recompresses .gif files
# Copyright (C) 2004-2020 by Brian Lindholm. This file is part of the # Copyright (C) 2004-2021 by Brian Lindholm. This file is part of the
# littleutils utility set. # littleutils utility set.
# #
# The opt-gif utility is free software; you can redistribute it and/or modify # The opt-gif utility 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 # it under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later version. # Software Foundation; either version 3, or (at your option) any later version.
# #
# The opt-gif utility is distributed in the hope that it will be useful, but # The opt-gif utility is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
# #
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# the littleutils. If not, see <https://www.gnu.org/licenses/>. # the littleutils. If not, see <https://www.gnu.org/licenses/>.
# get a valid temporary directory and set up traps
TMPWILD=`tempname -w opt-gif_$$` || exit 99
trap 'rm -f ${TMPWILD} ; exit 1' 1 2 3 13 15
trap 'rm -f ${TMPWILD} ; exit 0' 0
# get command-line options # get command-line options
TOUCH=n TOUCH='n'
VERBOSE=y VERBOSE='y'
while getopts hqt opts while getopts hqt opts
do do
case $opts in case $opts in
h) echo 'opt-gif LU_VERSION' h) echo 'opt-gif LU_VERSION'
echo 'usage: opt-gif [-h(elp)] [-q(uiet)] [-t(ouch)] GIF_filename ...' echo 'usage: opt-gif [-h(elp)] [-q(uiet)] [-t(ouch)] GIF_filename ...'
exit 0 ;; exit 0 ;;
q) VERBOSE=n ;; q) VERBOSE='n' ;;
t) TOUCH=y ;; t) TOUCH='y' ;;
*) echo 'opt-gif LU_VERSION' *) echo 'opt-gif LU_VERSION'
echo 'usage: opt-gif [-h(elp)] [-q(uiet)] [-t(ouch)] GIF_filename ...' echo 'usage: opt-gif [-h(elp)] [-q(uiet)] [-t(ouch)] GIF_filename ...'
exit 1 ;; exit 1 ;;
esac esac
done done
shift `expr ${OPTIND} - 1` shift $((${OPTIND}-1))
# set up traps
trap 'rm -f $TMPGIF ; exit 1' 1 2 3 13 15
# run through files # run through files
declare -i S0=0 S1=0
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
# make sure we can read and modify file # make sure we can read and modify file
if [ ! -f "$1" -o ! -r "$1" -o ! -w "$1" ]; then if [ ! -f "$1" -o ! -r "$1" -o ! -w "$1" ]; then
echo "opt-gif warning: $1 is not a writeable non-directory file" echo "opt-gif warning: $1 is not a writeable non-directory file"
shift; continue shift; continue
fi fi
# make sure it's a GIF # make sure it's a GIF
imagsize "$1" | grep -q 'type=gif' imagsize "$1" | grep -q 'type=gif'
OUT="$?" if [ $? -ne 0 ]; then
if [ "$OUT" -ne 0 ]; then
echo "opt-gif warning: $1 is not a GIF" echo "opt-gif warning: $1 is not a GIF"
shift; continue shift; continue
fi fi
# run through gifsicle # run through gifsicle
TMPGIF=`tempname -s .gif opt-gif_$$` || exit 99 TMPGIF=$(tempname -s .gif opt-gif_$$) || exit 99
gifsicle --careful -O3 --no-warnings < "$1" > ${TMPGIF} gifsicle --careful -O3 --no-warnings < "$1" > $TMPGIF
# ensure that new file is smaller # ensure that new file is smaller
if [ "$TOUCH" = 'y' ]; then if [ "$TOUCH" = 'y' ]; then
touch -r "$1" ${TMPGIF} touch -r "$1" $TMPGIF
fi fi
S0=`filesize "$1"` S0=$(filesize "$1")
S1=`filesize "$TMPGIF"` S1=$(filesize $TMPGIF)
if [ "$S1" -lt "$S0" ]; then if [ $S1 -lt $S0 ]; then
cp --preserve=timestamps ${TMPGIF} "$1" cp --preserve=timestamps $TMPGIF "$1"
if [ "$VERBOSE" = 'y' ]; then if [ "$VERBOSE" = 'y' ]; then
echo "$1: ${S0} vs. ${S1}" echo "$1: $S0 vs. $S1"
fi fi
else else
if [ "$VERBOSE" = 'y' ]; then if [ "$VERBOSE" = 'y' ]; then
echo "$1: unchanged" echo "$1: unchanged"
fi fi
fi fi
# clean up afterwards # clean up afterwards
rm -f ${TMPGIF} rm -f $TMPGIF
shift shift
done done
rm -f ${TMPWILD}
 End of changes. 14 change blocks. 
24 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)