Seth Burgess wrote:

How exactly are you running it?  If you're not supplying the
parameters to it, it will try to start the dialog, which will require
Gtk which requires an X server.


I started the gimp server using this:

gimp --no-interface --batch '(extension-perl-server 0 0 0)' &

The script looks like this:

#!/usr/bin/perl

use Gimp ":auto";
use Gimp::Fu;

# create a footer image

sub newimage {
    my ($width, $height,
        $backgroundcolor, $foregroundcolor,
        $borderSize, $borderColor,
        $typeFace, $typeSize, $typeColor,
        $dividerAboveSize, $dividerAboveWidth, $dividerAboveColor,
        $text,
        $dividerBelowSize, $dividerBelowWidth, $dividerBelowColor,
        $divider_offset
        ) = @_;


    # Create a new image
    $img = gimp_image_new($width, $height, RGB);

    # Create a new layer
$layer = gimp_layer_new($img, $width, $height, RGB, "Layer 1", 0, NORMAL_MODE);

    # define the background colors
    # $backgroundcolor = "#0000FF"; # blue
    # $foregroundcolor = "#FF0000"; # red
    # $backgroundcolor = $color1;
    # $foregroundcolor = $color2;

    gimp_palette_set_background($backgroundcolor);
    gimp_palette_set_foreground($foregroundcolor);

    # add the layer to the image
    gimp_image_add_layer($img, $layer, -1);

    # gimp_selection_all($img);
    gimp_layer_add_alpha($layer);
    gimp_drawable_fill($layer,TRANS_IMAGE_FILL);
    # gimp_selection_border($img, 3);
    #script_fu_addborder($img, $layer, 3, 3, "#000000", "100");

    # gimp_palette_set_background("#000000");

    # change the foreground color
    gimp_palette_set_background($borderColor);

    # draw the border
    # define first region
gimp_rect_select ($img, 0, 0, $width, $borderSize, 2, 0, 0); # (x1, y1, x2, y2)
    # fill the region
    gimp_bucket_fill($layer,BG_BUCKET_FILL,0,100,100,0,0,0);

    # define the second region
    $height_sec_region = $height - $borderSize;
gimp_rect_select ($img, 0, $height_sec_region, $width, $height, 2, 0, 0);
    # fill the second region
    gimp_bucket_fill($layer,BG_BUCKET_FILL,0,100,100,0,0,0);

    # define the left lateral region
    gimp_rect_select($img, 0, 0, $borderSize, $height, 2, 0, 0);
    # fill the region
    gimp_bucket_fill($layer,BG_BUCKET_FILL,0,100,100,0,0,0);

    # define the right lateral region
    $width_lat_region = $width - $borderSize;
    gimp_rect_select($img, $width_lat_region, 0, $width, $height, 2, 0, 0);
    # fill the region
    gimp_bucket_fill($layer,BG_BUCKET_FILL,0,100,100,0,0,0);

    # create the dividers
    # upper divider
    # calculate the width of divider
$x_start_above_div = (($width - ($dividerAboveWidth/100) * $width)/2) + $borderSize;
    $x_end_above_div = ($dividerAboveWidth/100) * $width - $borderSize * 2;
gimp_rect_select($img, $x_start_above_div, $divider_offset, $x_end_above_div, $dividerAboveSize, 2, 0, 0);
    # fill the region
    # change the background color
    gimp_palette_set_background($dividerAboveColor);
    gimp_bucket_fill($layer,BG_BUCKET_FILL,0,100,100,0,0,0);

    # lower divider
    # calculate the y coordinates for the divider
    $y_start_below_div = $height - ($divider_offset+$dividerBelowSize);
    $y_end_below_div = $dividerBelowSize;
    # calculate the width of divider
$x_start_below_div = (($width - ($dividerBelowWidth/100) * $width)/2) + $borderSize;
    $x_end_below_div = ($dividerBelowWidth/100) * $width - $borderSize * 2;
gimp_rect_select($img, $x_start_below_div, $y_start_below_div, $x_end_below_div, $y_end_below_div, 2, 0, 0);
    # fill the region
    # change the background color
    gimp_palette_set_background($dividerBelowColor);
    gimp_bucket_fill($layer,BG_BUCKET_FILL,0,100,100,0,0,0);

    # my $font = qq{-*-agenda-medium-r-normal-*-24-*-*-*-*-*-*-*};

    # set the foreground with the font color
    gimp_palette_set_foreground($typeColor);
    my $text_layer = gimp_text_fontname($layer, 0, 0, $text,
                                        -1, #border
                                        1, #antialias
                                        $typeSize, #size
                                        0, #size type
                                        $typeFace
                                        );

    # determine the position of the text
    my $texty = $height/2 - $text_layer->height/2;
    my $textx = $width/2 - $text_layer->width/2;

    # pull out text layer we were checking size and fonts on.
    gimp_image_remove_layer($img,$text_layer);

    # create again the layer
    $text_layer = gimp_text_fontname($layer, $textx, $texty, $text,
                                        -1, #border
                                        1, #antialias
                                        $typeSize, #size
                                        0, #size type
                                        $typeFace
                                        );

    gimp_floating_sel_anchor($text_layer);

    # draw the border (cannot define its width)
    # script_fu_addborder($img, $layer, 3, 3, "#000000", "1");

#$layer2 = gimp_layer_new($img, 725, 5, RGB, "Layer 2", 0, NORMAL_MODE);
    #gimp_image_add_layer($img, $layer2, -1);
    #gimp_selection_all($img);
    #gimp_layer_add_alpha($layer2);
    #gimp_drawable_fill($layer2,FG_IMAGE_FILL);

    # Set the background to the required color
    # gimp_palette_set_foreground($color1);
    # gimp_palette_set_background($color2);

    # Paint the layer
    #gimp_edit_fill($layer, BG_IMAGE_FILL);
    #gimp_edit_fill($layer2, FG_IMAGE_FILL);

    # delete the image
    # gimp_image_delete($img);
    # Return the image
    return $img;
}

register
    "newimage2",                 # fill in name
    "Create a footer",  # a small description
    "gimp",       # a help text
    "Andrei Simion",            # Your name
    "",        # Your copyright
    "2005-04-17",              # Date
    "<Toolbox>/Xtns/Perl-Fu/Tutorial/newimage",   # menu path
    "*",                       # Image types
    [
     [PF_INT,   "width",      "Img width", "725"],
     [PF_INT,  "height",      "Img height", "80"],
     [PF_COLOR, "bckg_color",     "background color", [255,0,0]],
     [PF_COLOR, "fg_color",     "foreground color", [0, 0, 255]],
     [PF_INT, "border_size",  "Border size", "1"],
     [PF_COLOR, "border_color",     "border color", [0, 0, 255]],
[PF_FONT, "font", "font", "-*-utopia-bold-r-*-*-70-*-*-*-*-*-*-*"],
     [PF_INT, "font_size",  "Font size", "32"],
     [PF_COLOR, "font_color",     "Font color", [0, 0, 255]],
     [PF_INT, "divider_above_size",  "Divider above size", "1"],
     [PF_INT, "divider_above_width",  "Divider above width", "100"],
[PF_COLOR, "divider_above_color", "Divider above color", [0, 0, 255]],
     [PF_STRING,"text",    "Text", "some text"],
     [PF_INT, "divider_below_size",  "Divider below size", "1"],
     [PF_INT, "divider_below_width",  "Divider below width", "100"],
[PF_COLOR, "divider_below_color", "Divider below color", [0, 0, 255]],
     [PF_INT, "divider_offset",  "Divider offset", "10"]
    ],
    \&newimage;

exit main();

Andrei


On 5/27/05, Andrei Simion <[EMAIL PROTECTED]> wrote:

I managed to start the Gimp server. I read that one of its new features
is that you don't need the X to run it. But, when I run an old Perl
script I got this warning:

1117202349: accepted unix connection
Gtk-WARNING **: cannot open display:   at
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Gimp.pm line 264.
1117202349: closing connection 11 (0 requests in 0 seconds)

I think the Perl script needs a display, but this can be obtained only
by running X, which I shouldn't run.

Another question would be whether the old Perl scripts (written for 1.x
versions of Gimp) run on 2.2.

Thanks,
Andrei



Andrei Simion wrote:


Hi all,

I have to run the Gimp server on a RH machine, but I don't have any clue
how it can be started. Where can I find some documentation on that? I
mention that the Gimp server will be accesed through a Perl interface.

Regards,
Andrei Simion


_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer



_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer

Reply via email to