On Sat, 2009-08-29 at 13:34 -0300, Joao S. O. Bueno wrote:
> On Tuesday 25 August 2009, Michael wrote:
> > Hello,
> >
> > I'm trying to use a Perl script that makes use of Perl's Gimp module (the
> > simplified version Gimp::Fu) for Gimp Gimp versions 2.x. (I have GIMP 2.6.2
> > under OpenSUSE 11.2).
> >
> > Whenever I try to execute the script from the Filters > Perl-Fu menu option
> > I
> >
> > get error messages like:
> > > Calling error for procedure 'gimp-procedural-db-proc-info':
> > > Procedure 'gimp-gimp-image-new' not found.
> >
> > The funny thing is that my procedures are correctly called in the script
> > ('gimp-image-new', 'gimp-layer-new' ...), but somehow a 'gimp' is prepended
> > here.
> 
> Hi Michael  -- 
> the sad news is that I haven't heard, in recent years of anyoen amitaining 
> teh 
> GIMP-PERL bindings  It may very well be that they are in an unusable state.
> 
> Maybew someone cna come with more promising news for you - but otherwise, I'd 
> suggest porting your scripts to gimp-python for the time being.
> 
>   js
>   -><-
> 
I wrote some plug-ins back in February and remember seeing this problem.
I'm using Gimp 2.6.6 on Ubuntu 9.04 with libgimp-perl 2.0.dfsg
+2.2pre1.dfsg-5.  

If I remember correctly, this isn't really an error, it's an
informational message that keeps popping alert boxes up.  I got around
it by setting the message handler to console while the script was
running and then resetting it to it's previous value on exit.

In case I don't remember correctly here is a Perl-Fu script that runs
under gimp 2.6.6.  Feel free to play with it, reuse whatever part you
want or just trace it and watch what happens (uncomment the trace and
start it from a terminal).

drop_shadow.pl

#!/usr/bin/perl

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

# create a drop shadow
# and framing it.  Derived from drop-shadow.scm
#
# Created by Bill Ferguson <b...@moonshinecomputers.com>

use Gimp qw(:auto __ N_);
use Gimp::Fu;

#Gimp::set_trace(TRACE_ALL);

sub max {
   $_[0] > $_[1] ? $_[0] : $_[1];
}

sub min {
   $_[0] < $_[1] ? $_[0] : $_[1];
}

sub  drop_shadow {
        my($img, $drawable, $shadow_transl_x, $shadow_transl_y, $shadow_blur,
                $shadow_color, $shadow_opacity, $allow_resize) = @_;

        my $old_handler = message_get_handler();
        message_set_handler(CONSOLE);
        
        my $old_fg = context_get_foreground();
        my $old_bg = context_get_background();

        eval { $img->undo_group_start };
                
        $shadow_blur = max($shadow_blur, 0);
        $shadow_opacity = max(min($shadow_opacity, 100), 0);
        my $imgtype = $drawable->type_with_alpha();
        my $image_height = $img->height();
        my $image_width = $img->width();
        my($from_selection, $active_selection, $shadow_layer) = 0;
        

        #
        # code goes here....
        #
        
        my $cur_layer = $img->get_active_layer();
        $drawable->layer_add_alpha();
        
        if($img->selection_is_empty()){
                $drawable->selection_layer_alpha();
                $from_selection = 0;
        }
        else{
                $from_selection = 1;
                $active_selection = $img->selection_save();
        }
        
        my($not_empty, $x1, $y1, $x2, $y2) = $img->selection_bounds();
        my $select_width = $x2 - $x1;
        my $select_height = $y2 - $y1;
        my $shadow_width = $select_width + ($shadow_blur * 2);
        my $shadow_height = $select_height + ($shadow_blur * 2);
        my $shadow_offset_x = $x1 - $shadow_blur;
        my $shadow_offset_y = $y1 - $shadow_blur;
        
        if($allow_resize){
                my $new_image_width = $image_width;
                my $new_image_height = $image_height;
                my($image_offset_x, $image_offset_y) = 0;
                
                if(($shadow_offset_x + $shadow_transl_x) < 0){
                        $image_offset_x = 0 - ($shadow_offset_x + 
$shadow_transl_y);
                        $shadow_offset_x = 0 - $shadow_transl_x;
                        $new_image_width += $image_offset_x;
                }
                
                if(($shadow_offset_y + $shadow_transl_y) < 0){
                        $image_offset_y = 0 - ($shadow_offset_y + 
$shadow_transl_y);
                        $shadow_offset_y = 0 - $shadow_transl_y;
                        $new_image_height += $image_offset_y;
                }
                
                if(($shadow_width + $shadow_offset_x + $shadow_transl_x) >
$new_image_width){
                        $new_image_width = $shadow_width + $shadow_offset_x +
$shadow_transl_x;
                }
                
                if(($shadow_height + $shadow_offset_y + $shadow_transl_y) >
$new_image_height){
                        $new_image_height = $shadow_height + $shadow_offset_y +
$shadow_transl_y;
                }
                
                $img->resize($new_image_width, $new_image_height, 
$image_offset_x,
$image_offset_y);
        }
        
        $shadow_layer = $img->layer_new($shadow_width, $shadow_height,
$imgtype, "Drop Shadow", $shadow_opacity, NORMAL_MODE);
        $img->add_layer($shadow_layer, -1);
        $shadow_layer->set_offsets($shadow_offset_x, $shadow_offset_y);
        
        $shadow_layer->drawable_fill(TRANSPARENT_FILL);
        context_set_background($shadow_color);
        $shadow_layer->edit_fill(BACKGROUND_FILL);
        $img->selection_none();
        if($shadow_blur > 1.0){
                plug_in_gauss_rle($shadow_layer, $shadow_blur, TRUE, TRUE);
        }
        $shadow_layer->translate($shadow_transl_x, $shadow_transl_y);
        
        if($from_selection){
                $shadow_layer->selection_load($active_selection);
                $shadow_layer->edit_clear();
                $shadow_layer->remove_channel($active_selection);
        }
        
        if(!$drawable->layer_is_floating_sel() && !$from_selection){
                $img->raise_layer($cur_layer);
        }
        $img->set_active_layer($cur_layer);

        eval { $img->undo_group_end };
        displays_flush();
        message_set_handler($old_handler);
        
        context_set_foreground($old_fg);
        context_set_background($old_bg);
        
        return();
}

register "drop_shadow",
         "Create a drop shadow",
         "Create a drop shadow",
         "Bill Ferguson",
         "Bill Ferguson <bi...@moonshinecomputers.com>",
         "2009-02-11", N_"<Image>/Filters/Render/Drop Shadow...", "RGB*,
GRAY*",
         [
          [PF_SPINNER,          "offset_x",                     "Offset in the 
x direction",            8, [-4096,
4096, 1]],
          [PF_SPINNER,          "offset_y",                     "Offset in the 
y direction",            8, [-4096,
4096, 1]],
          [PF_SPINNER,          "blur_radius",          "Size of the blur",     
                                15, [0, 1024,
1]],
          [PF_COLOR,            "color",                        "Color of the 
shadow",                          [0, 0, 0]],
          [PF_SLIDER,           "opacity",                      "Opacity of the 
shadow",                        80, [0, 100,
1]],
          [PF_TOGGLE,           "allow_resizing",       "Allow resizing of the 
image",          TRUE]
         ],
                \&drop_shadow;
                
exit main;



=head1 LICENSE

Copyright Bill Ferguson.  
Distributed under the same terms as Gimp-Perl.

=cut

> 
> 
> >
> > Have you seen this before? How can I solve the problem?
> >
> > Thanks in advance for your help,
> >
> > Michael
> 
> 
> _______________________________________________
> Gimp-user mailing list
> Gimp-user@lists.XCF.Berkeley.EDU
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply via email to