Re: [Gimp-user] applying effects in batch mode

2001-11-25 Thread Bret Hughes

Mario Bittencourt wrote:

 Hi,

 I am a Photoshop user (nobody's perfect) and I've been playing with
 Gimp for a while.  Since photoshop can not do what I want (at least do
 not know how) I've decided to try to do the same thing under gimp.

 I need to apply a set of effects (such as resize, ajust levels,
 shapen etc) to a large group of files, saving them in another directory.

 I've developed an action under photoshop but it forces me to open
 the files manually and presse the  Go  button for each one.

 What I'd like to do is use Gimp (or other tool - in this case email
 me privately) to open all files located in a cretain directory, apply a
 predefined set of effects  and save the files with the same name in a
 different directory.

 Since I've never worked with script-fu (I suppose I'll have to use
 that) I'd like to know if someone could send me some tips about this or
 even snippets of code to do what I want.

Mario-

 I don't know what platform you are working on but I recently managed to
get some batch processing done in Linux using perl and the gimp-perl
module.  In fact I have been lurking this list for a week or so as I was
trying to get this working.

Here is an overview of what I did to get this working and if anyone has any
comments like Dummy, you did not have to go through all that you could
have done blah blah I would certainly be grateful.

First, A little background.  I have a rudimentary knowledge of perl and
have been fairly involved in linux adminstration for several years. I have
an extremely basic working knowledge of gimp and almost no other graphic
tools.

The task that I ws trying to automate was the opening of a an animated gif
that is sent to us from a business partner and that is huge, 3.5 MB or so,
and sometimes comes with the layers compositing and sometimes replacing.  I
need them to be replaced.  I found, as I was trying to learn about this
image and  why it was compositing rather than replacing that if I saved it
in gimp with the correct layer defaults, that the file size was reduced to
less than 200K.

This was perfect if only I could figure out a way to automate the gimp
steps.

I wanted all software installations to be accomplished via rpm to
facilitate the recreation of the environment on other machines.  The
process is running in cron as a normal user

There are several issues I had to overcome:

  1. 1. upgrading gimp to the latest I could find in order to justifiably
 ask for help.  The server and my test box are both running redhat 6.2
 with several, but as I found not all, the upgrades availible from
 redhat.  I found an rpm that worked perfectly at
 ftp://ftp.gimp.org/pub/gimp/binary/RPMS/
  2. 2. upgrading perl with the modules that would provide the hooks into
 gimp.
  3. 3. running on a machine with no X (gui interface ) running
  4. 4. Figuring out what the syntax was in perl to call gimp
  5. 5. trouble shooting errors

The packages that I installed were as follows:
perl-Gtk-Perl 0.7000 6 from
ftp://ftp.redhat.com/pub/redhat/linux/6.2/cpan/i386/
Mesa 3.2 2 redhat cd
perl-PDL 2.003 6
ftp://ftp.redhat.com/pub/redhat/linux/6.2/cpan/i386/
gtk+ 1.2.8 1
ftp://ftp.gtk.org/pub/gtk/binary/RPMS/RedHat-6.2/RPMS/i386/
gimp 1.2.0 1  ftp://ftp.gimp.org/pub/gimp/binary/RPMS/
gimp-perl 1.2.0 1  ftp://ftp.gimp.org/pub/gimp/binary/RPMS/
XFree86-Xvfb 3.3.6 20 redhat cd


Ther perl modules alread installed were:
perl 5.00503 2
perl-libnet 1.0605 2
perl-Tk 800.018 1
perl-HTML-Parser 3.05 6
perl-libwww-perl 5.47 6
perl-URI 1.05 6
perl-Net-SSLeay 1.05 5

I had to upgrade glib package to install the new gtk+ on one of the boxes

I then had to make sure there was an X display that gimp could use,
otherwise the script would hang and gimp showed up in a ps axf output as
defunct.

This was not a problem until I moved to the X-less server.  On the server I
started Xvfb with the following line in a script startXvfb:

scripts]$ cat startXvfb
Xvfb :1 -screen 0 10x10x8 -pixdepths 1 -fp
/usr/X11R6/lib/X11/fonts/misc/,/usr/X11R6/lib/X11/fonts/Speedo/,/usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/75dpi/

I leave this running on the server started as the user the cron process
runs as with the following command line:

nohup startXvfb 

The perl program that does my conversion is called radarsave.pl:

scripts]$ cat radarsave.pl
#!/usr/bin/perl  -w
print entering $0\n;
use File::Basename;
$numargs = @ARGV;
$progname= basename($0);

if  ( $numargs != 2 ){
print  the number of args is $numargs\n;
print Incorrect number of arguments. \nUsage $progname infile outfile\n;
exit 1;
}
use Gimp;
use Gimp::Fu;
#set_trace is important to see what gimp is doing.
#You don't get this in script-fu as far as I could learn
Gimp::set_trace(TRACE_ALL);
Gimp::init;
print `date '+%b %d %T' `.loading $ARGV[0]\n;
my $img = Gimp-file_gif_load($ARGV[0],$ARGV[0]);
print return code = $?\n;
print `date '+%b 

Re: [Gimp-user] applying effects in batch mode

2001-11-25 Thread Bret Hughes

magnetHead wrote:

 I just want to say thank you for posting the script example, that was
 awesome. I'll be writing scripts in a few hours thanks to you.

Glad it was of use.

Bret

___
Gimp-user mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user