Gimp::Fu

Jan Kasprzak kas na informatics.muni.cz
Pondělí Prosinec 18 15:08:49 MET 2000


	Zdravim,

	potreboval jsem si napsat kratky plug-in pro Gimp, ktery mi kolem
obrazku vytvori ramecek (neco jako maji fotky na
http://www.fi.muni.cz/~kas/scan/, jenze delany automaticky, ne rucne).
Napsal jsem to pomoci prilozeneho skriptu, ale narazil jsem na problem:
Kdyz prislusne funkci reknu, ze ma mit parametry (treba sirka ramecku,
barvy, atd), Gimp po startu sice skript nacte (zmeni se access time),
ale nezaradi prislusnou polozku do menu. Kdyz zakomentuju definice
vsech argumentu, je vsecho OK.

	Rekl jsem si, ze se podivam, jak to delaji jini. Jenze ouha:
z baliku gimp-perl ani jeden plug-in, ktery ma parametry, neni po startu
Gimpu zarazen do menu. Netusite nekdo, kde je zakopany pes? System
je Red Hat 7.0 se vsemi updaty

-Yenya

----------------------------------------------
$ rpm -qa | grep -i gimp
gimp-devel-1.1.25-1
gimp-1.1.25-1
gimp-perl-1.1.25-1
xsane-gimp-0.61-3
gimp-data-extras-1.1.20-3
----------------------------------------------
#!/usr/bin/perl -w

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

register "image_bw_frame",
	"Create a two-color frame",
	"Create a two-color frame",
	'Jan "Yenya" Kasprzak',
	'(c) 2000 Jan Kasprzak',
	'2000-12-18',
	'<Image>/BW Frame...',
	'*',
	[
### Kdyz se nasledujici radky odkomentuji, Gimp skrit nezaradi do menu:
#		[ PF_INT32,	"width", "Frame width", 5 ],
#		[ PF_INT32,	"offset", "2nd color offset", 3 ],
#		[ PF_COLOR,	"bgcolor", "Background color", [ 0, 0, 0 ],  ],
#		[ PF_COLOR,	"fgcolor", "Foreground color", [ 255, 255, 255 ] ],
	],
	[],
	['gimp-1.1'],
	\&image_bw_frame;

exit main;

sub image_bw_frame {
	my ($img, $drawable, $width, $offset, $bgcolor, $fgcolor) = @_;

	$width	 ||= 5;
	$offset	 ||= 3;
	$bgcolor ||= [ 0, 0, 0 ];
	$fgcolor ||= [ 255,255,255 ];

	gimp_undo_push_group_start($img);

	my $img_width = gimp_image_width($img);
	my $img_height = gimp_image_height($img);

	gimp_palette_set_foreground($fgcolor);
	gimp_palette_set_background($bgcolor);

	gimp_selection_all($img);
	gimp_image_resize($img, $img_width + 2*$width, $img_height + 2*$width,
		$width, $width);
	gimp_layer_resize($drawable, $img_width + 2*$width, $img_height
		+ 2*$width, $width, $width);
	gimp_selection_invert($img);

	gimp_edit_fill($drawable, 1);
	gimp_rect_select($img, $offset, $offset, $img_width + $width-$offset + 1,
		$img_height + $width-$offset + 1, 2, 0, 0,);
	gimp_brushes_set_brush('Circle (01)');
	gimp_edit_stroke($drawable);
	gimp_selection_none($img);

	gimp_undo_push_group_end($img);
}
----------------------------------------------

-- 
\ Jan "Yenya" Kasprzak <kas at fi.muni.cz>       http://www.fi.muni.cz/~kas/
\\ PGP: finger kas at aisa.fi.muni.cz   0D99A7FB206605D7 8B35FCDE05B18A5E //
\\\             Czech Linux Homepage:  http://www.linux.cz/              ///
//  (and don't ask me about the extraneous parenthesis.  I bet some LISP  \\
/ programmer felt alone and decided to make it a bit more homey).  (Linus) \


Další informace o konferenci Perl