public inbox for test-list@sourceware.org
help / color / mirror / Atom feed
* This is a normal message
@ 2001-11-11  9:05 Jason Molenda
  0 siblings, 0 replies; only message in thread
From: Jason Molenda @ 2001-11-11  9:05 UTC (permalink / raw)
  To: test-list

[-- Attachment #1: Type: text/plain, Size: 37 bytes --]

Watch my normality.  And a patch.

J

[-- Attachment #2: pa.txt --]
[-- Type: text/plain, Size: 3612 bytes --]

===================================================================
RCS file: makethumbs.sh,v
retrieving revision 1.56
diff -up -r1.56 makethumbs.sh
--- makethumbs.sh	2001/11/07 05:25:44	1.56
+++ makethumbs.sh	2001/11/08 06:09:08
@@ -208,6 +208,7 @@ init_defaults ()
   DEFAULT_reduce_trigger_width=1024
   DEFAULT_reduce_height=600
   DEFAULT_reduce_width=800
+  DEFAULT_remove_originals=0
   t=`pwd`
   DEFAULT_pwd_english=`basename "$t"`
   DEFAULT_rotation_file="rot-state.txt"
@@ -223,6 +224,7 @@ init_defaults ()
   GLOBAL_reduce_width=$DEFAULT_reduce_width
   GLOBAL_pwd_english="$DEFAULT_pwd_english"
   GLOBAL_rotation_file=$DEFAULT_rotation_file
+  GLOBAL_remove_originals=$DEFAULT_remove_originals
 }
 
 parse_args ()
@@ -262,6 +264,10 @@ parse_args ()
              ARGV_use_two_windows=1
              GLOBAL_use_two_windows=$ARGV_use_two_windows
            ;;
+      --remove-orig*)
+             ARGV_remove_originals=1
+             GLOBAL_remove_originals=$ARGV_remove_originals
+           ;;
       --disable-reduce)
              ARGV_reduce_big_pics=0
              GLOBAL_reduce_big_pics=$ARGV_reduce_big_pics
@@ -339,6 +345,10 @@ Usage: `basename $0` [--maxthumbsize=n] 
 --disable-reduce  Don't create a reduced img if the picture is large
 
 --use-two-windows Bring up a new window to see images, default is `[ $DEFAULT_use_two_windows -eq 1 ] && echo enabled || echo disabled`
+--remove-originals Remove original images if we make reduced versions.
+                   Useful when disk space is limited; default is `[ $DEFAULT_use_two_windows -eq 1 ] && echo enabled || echo disabled`
+                   WARNING!!! This option *will* remove your original images if 
+                              reduced images are available!
 
 Run this script in a directory of JPEG files to create thumbnail images and
 an index.html. If an index.html is already present, its HTML is sent to stdout.
@@ -455,10 +465,50 @@ print_image_entry ()
   create_reduced "$pie_fn"
   was_reduced=$RETURN_was_reduced
 
+  if [ $was_reduced -eq 1 ]
+  then
+    maybe_remove_original "$pie_fn" $was_reduced
+    if [ $RETURN_original_removed -eq 1 ]
+    then
+      was_reduced=0
+    fi
+  fi
+
   print_image_link $thumb_width $thumb_height $was_reduced "$pie_fn" 
   print_image_size "$pie_fn"
 }
 
+maybe_remove_original ()
+{
+  mro_name="$1"
+  mro_was_reduced="$2"
+  RETURN_original_removed=0
+  RETURN_reduced_still_around=1
+
+  [ "$mro_was_reduced" -eq 0 ] && return
+  [ "$GLOBAL_remove_originals" -eq 0 ] && return
+
+  source_name_to_reduced_name "$mro_name"
+  mro_reduced_name="$RETURN_reduced_name"
+
+  if [ -f "$mro_name" -a -f "$mro_reduced_name" -a -s "$mro_reduced_name" ]
+  then
+    mv "$mro_name" "${mro_name}.bak"
+    mv "$mro_reduced_name" "$mro_name"
+  fi
+    
+  if [ ! -f "$mro_reduced_name" -a -f "$mro_name" -a -s "$mro_name" ]
+  then
+    rm -f "${mro_name}.bak"
+    RETURN_original_removed=1
+    RETURN_reduced_still_around=0
+  else
+    echo ERROR: I got confused while trying to remove original file >&2
+    echo ERROR: \"$mro_name\"!  Aborting... >&2
+    exit 1
+  fi
+}
+
 get_file_english_name ()
 {
   gfen_fn="$*"
@@ -751,7 +801,7 @@ print_html_footer ()
 
 <!-- This file generated automatically by makethumbs.sh, written by 
       Jason Molenda, makethumbs(AT)molenda.com.
-      RCS Id: $Id: makethumbs.sh,v 1.56 2001/11/07 05:25:44 molenda Exp molenda $
+      RCS Id: $Id: makethumbs.sh,v 1.56 2001/11/07 05:25:44 molenda Exp $
       The latest version of this script is always available at 
                http://www.molenda.com/makethumbs/  -->
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-11-13  9:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-11  9:05 This is a normal message Jason Molenda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).