Re: gimp 1.2.0--a few questions

2001-01-01 Thread Chetan Dhavse


WISH YOU ALL A VERY HAPPY NEW YEAR.

On Thu, Dec 28, 2000 at 06:42:40PM +0530, Chetan Dhavse [EMAIL PROTECTED] wrote:
 Subroutine gimp_text_get_extents_fontname redefined at 
/opt/other/src/perl-5.6.0/lib/site_perl/5.6.0/i686-linux/Gimp.pm line 539.

this is very strange but is most probably a problem with your script
(double fork or something similar) - how do you start your script, and can
you send a stripped-down version of your script that shows this error?

I am sending you all a small script, maybe this will give you an idea
as to what I am doing(or doing wrong).

never-the-less this script also gives me the above warnings.

The script is in two part 
1)Shell script in which I start gimp and Xvfb
and then call the main gimp-perl program.(tests) 
Please ignore the linux server name,kosi(river in India) in this case

The next is the gimp-perl script (tests) which contains a main program 
and subroutines.
I have used similar subroutines for other gimp functions as well.


Is this the right way to start a gimp-perl program? or the
only way,I had used "sub net" to start earlier (1.1.04)
but does not work overhere.(1.2.0)
do I have to use the register method.(This is not a plug-in)?
Please do suggest me a better way if there is one.

2)I refer to DB browser for assistance on in/out parameters
In  many functions the first parameter is interactive/non_in...
which is mentioned as IN INT32 (integer) therefore I put "1" 
for non_interactive
and so plug_in_autocrop(1,$image,$layer);
which does not work.


Thanks for the Patience

Gimper

Chetan


### SHELL SCRIPT 
#!/bin/sh

DISPLAY=kosi:1
export DISPLAY

Xvfb :1 

gimp --display kosi:1.0 --no-interface --version 

./rot -o a.gif

killall gimp 
killall Xvfb
###END SHELL SCRIPT 


### GIMP PERL ##
#!/opt/bin/perl -w

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

register
"rotate",
"Circle", 
"created using Gimp",
"Chetan",   
"cmie", 
"2000-06-12",
"Toolbox/Xtns/Perl-Fu/Tutorial/chart",
"*",
[
],
\trial;  

exit main();

sub trial 
{

$font1="-fromttf-arial-bold-i-normal--0-0-0-0-p-0-iso8859-1";
$font2="-fromttf-couriernew-bold-i-normal--0-0-0-0-m-0-iso8859-1";

#$font3="-fromttf-verdana_iso8859_1-bold-i-normal--0-0-0-0-p-0-adobe-fontspecific";
#$font4="-misc-fixed-medium-r-normal--0-0-75-75-c-0-koi8-r";
#$font5="-dec-terminal-medium-r-normal--0-0-75-75-c-0-dec-dectech";

$text = "THIS IS A TEST";
$tsize = 15;
$angle = 0; 
$bgcol = [100,100,100];
$col = [233,200,150];

my(@retval )= text_extent($text,$font1,$tsize,$angle);

print join("|",@retval),"\n"; 
($img,$layer)=init_img(500,500);
gimp_image_set_resolution($img,120,120);
gimp_palette_set_background($bgcol);
gimp_edit_fill($layer,0);
gimp_ellipse_select($img, 250, 250, 100, 100, 0, 1, 1, 1);
gimp_palette_set_foreground($col);
gimp_bucket_fill($layer,0,0,100,100,1,100,100);
write_text($img,$layer,200,200,$text,$font2,$tsize,$col,$angle);
write_text($img,$layer,100,100,$text,$font1,$tsize,$col,$angle);
plug_in_autocrop($img,$layer);
return $img;
}


sub init_img
{
# initialisation of image and layer and adding layer to the image

my ($img_width, $img_height) = @_;
my ($img, $layer);
$img = gimp_image_new($img_width, $img_height, RGB);
$layer = gimp_layer_new($img,$img_width,$img_height,RGB,"Layer 1",100,0);
gimp_image_add_layer($img, $layer, -1);
gimp_drawable_fill($layer,2);
return ($img, $layer);
}

sub text_extent
{
#for calculating the width and the height of the text's bounding box.
my ($text,$font,$size,$angle) = @_;
my ($width,$height,$ascent,$decent,$wth,$ht) = (0,0,0,0,0,0);
my($w1,$w2,$h1,$h2);

($wth, 
$ht,$ascent,$decent)=gimp_text_get_extents_fontname($text,$size,0,$font); 
my $ang_wth = $wth;
$width = $wth;
$height = $ht;
$w1 = $wth;
$w2 = 0;
if(defined($angle)  $angle != 0)
{
$ang_wth = $ht/sin($angle);
$ang_wth = abs($ang_wth);
$ang_wth = sprintf("%0.0f",$ang_wth);
$w1 = $wth * abs(cos($angle));
$w2 = $ht * abs(sin($angle));
$h1 = $wth * abs(sin($angle));
$h2 = $ht * abs(cos($angle));
$width = sprintf("%0.0f",$w1 + $w2);
$height = sprintf("%0.0f",$h1 + $h2);
}
return($width,$height,$ang_wth,$w1,$w2,$wth,$ht);
}

sub write_text
{
# for writing text (eg. Title legends etc)
my($img,$layer,$x,$y,$text,$font,$size,$colour,$angle) = @_;
gimp_palette_set_foreground ($colour);

Re: gimp 1.2.0--a few questions

2001-01-01 Thread Chetan Dhavse



OOPS!!!
I forgot to change the perl script name in the shell script (both at the
bottom of my last mail) from "rot to "tests". 
well doesn't make much of a difference


Thankyou

Gimper 

Chetan





Re: gimp 1.2.0--a few questions

2000-12-28 Thread Marc Lehmann

On Thu, Dec 28, 2000 at 06:42:40PM +0530, Chetan Dhavse [EMAIL PROTECTED] wrote:
 Subroutine gimp_text_get_extents_fontname redefined at 
/opt/other/src/perl-5.6.0/lib/site_perl/5.6.0/i686-linux/Gimp.pm line 539.
 Subroutine gimp_bucket_fill redefined at 
/opt/other/src/perl-5.6.0/lib/site_perl/5.6.0/i686-linux/Gimp.pm line 539.
 
 Sorry but I am lost. The same warnings are for almost all the function

this is very strange but is most probably a problem with your script
(double fork or something similar) - how do you start your script, and can
you send a stripped-down version of your script that shows this error?

 The plug in "plug_in_autocrop" gives the following error if I use
 plug_in_autocrop(1,$img,$layer); (as mentioned in DB browers)

Certainly this is nowhere mentioned in DB browers, where did you get the "1"
from? Hardcoding constants is going to bite you. Either use
RUN_NONINTERACTIVE (or RUN_INTERACTIVE) or, better, just leave our the
unnecessary arguments, e.g.:

plug_in_autocrop($img,$layer);
plug_in_autocrop($layer);

or even

$layer-autocrop;

 but works fine if I use
 
 plug_in_autocrop(1,$layer);

Because 1 happens to be a valid image id. The first agrument is the
run_mode, which must be on the the three symbolic RUN_*-constants. The
second agrument must be an image and the third a layer. It happens thta
you can leave out the first two agruments, since they are redundant (no
runmode == noninteractive and a layer always belongs to some image).

This could also solve your problems above, since 5.6.0 is rather broken
with regards to error handling (this has been fixed in later snapshots, so
best use 5.005_03 or a current perl snapshot if you want sensible error
reporting) so the above could just be the effect of a runtime error that
doers not get reported but instead garbles perl's internal state.

-- 
  -==- |
  ==-- _   |
  ---==---(_)__  __   __   Marc Lehmann  +--
  --==---/ / _ \/ // /\ \/ /   [EMAIL PROTECTED] |e|
  -=/_/_//_/\_,_/ /_/\_\   XX11-RIPE --+
The choice of a GNU generation   |
 |