[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-artists
Subject:    Keep your xcf files
From:       Rik Hemsley <rik () rikkus ! demon ! co ! uk>
Date:       1999-08-15 13:01:49
[Download RAW message or body]

Hi,

I've made a script that converts xcf files to png using the gimp,
without having to do it all manually.

I suggested some time ago that we use xcf as the standard format
for passing icons around, to allow us to keep layer info, etc. This
script will allow easy batch conversion (in its default mode it
converts all xcf files in a dir + all subdirs).

If you save your work as xcf you can occasionally run this script
when you want pngs creating.

Cheers,
Rik

-- 
KDE - Colour Outside The Lines - http://www.kde.org

["xcf2png.sh" (application/x-shellscript)]

#!/bin/sh
# 
# Fancy xcf->png conversion utility
# (C) Copyright 1999 Rik Hemsley <rik@kde.org>
# 
# Get a list of .xcf files and choose compression level.
# This stuff may be edited to your own preferences.

# Default: `find . -type f -name '*.xcf' -print`
# Look in the current dir and all subdirs for .xcf files and convert them all.
# You can set this to what you like, e.g. just 'mypic.xcf'
# 
INPUTFILELIST=`find . -type f -name '*.xcf' -print`

# Default: 9
# More compression only eats CPU time at compression time. Decompression time
# is approximately constant. It's actually faster to decompress a more heavily
# compressed file as it takes less time to transfer it from backing store :)
# 
COMPRESSIONLEVEL=9



# ----------- You shouldn't need to edit anything below this line -------------

# Now set up some sensible defaults

SCRIPTDIR="${HOME}/.gimp/scripts"
SCRIPTFILE="${SCRIPTDIR}/xcf2png.scm"

# This function does the real work.

cat > ${SCRIPTFILE} << EOF
(define ( _xcf2png ifile ofile compression-level)
  (let* ( ( img ( car ( gimp-xcf-load 0 ifile ofile ) ) )
      ( drawable ( car ( gimp-image-active-drawable img ) ) ))
    (if ( > ( car ( gimp-image-get-layers img ) ) 1 )
      (gimp-image-merge-visible-layers img 0))
    ( file-png-save 1 img drawable ofile ofile 0 compression-level ) ) )
( script-fu-register "_xcf2png" "<Toolbox>/_xcf2png" "" "" "" "" "" )
EOF

# This function just calls the first for each input and output filename.

echo "( define ( xcf2png compression-level )" >> ${SCRIPTFILE}

for INPUTFILE in ${INPUTFILELIST}
do
  OUTPUTFILE=`echo ${INPUTFILE} | sed 's/\.xcf/.png/'`
  echo "  ( _xcf2png \"${INPUTFILE}\" \"${OUTPUTFILE}\" ${COMPRESSIONLEVEL} )"\
    >> ${SCRIPTFILE}
done

echo "  ( gimp-quit 0 ) )" >> ${SCRIPTFILE}

cat >> ${SCRIPTFILE} << EOF
( script-fu-register "xcf2png" "<Toolbox>/xcf2png" "" "" "" "" "" )
EOF

# Run the gimp in batch mode.
exec gimp --no-interface --batch "(xcf2png ${COMPRESSIONLEVEL})"



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic