#!/usr/bin/perl
# dimage_color_batch - Batch-process JPEG files with the 
#                      GIMP Dimage color plugin
#
# usage: dimage_color_batch file1 file2 ...
#
# Copyright (C) 2002 Laurent HOUDARD <lhoudard@netcourrier.com>

use strict;

use Gimp;
use Gimp::Fu;

# Gimp::set_trace (TRACE_ALL);
Gimp::init;

my ($input, $output);

foreach $input (@ARGV) 
{
    print "processing $input...\n";
    my $img = Gimp->file_jpeg_load ($input, $input);
    my $drw = $img->get_active_layer ();

    $drw->plug_in_dimage_color (1,  # gamma and tone correction
				0); # default tone correction curve

    ($output = $input) =~ s/(.*)\.jpg/$1_dc_fixed\.jpg/;

    print "writing $output\n";
    $drw->file_jpeg_save ($output, $output, 
			  0.75, # quality
			  0.0,  # smoothing
			  1,    # optimize
			  0,    # progressive
			  "",   # comment
			  0,    # subsampling
			  1,    # baseline
			  0,    # restart
			  0);   # DCT
}
