#!/usr/bin/perl
$black
=
"#000000"
;
$white
=
"#FFFFFF"
;
$font
=
"engraver"
;
$example
= 1;
Gimp::set_trace(TRACE_NAME);
sub
index_and_save($$) {
my
(
$img
,
$path
)=
@_
;
gimp_image_flatten(
$img
);
gimp_convert_indexed_palette(
$img
,1,0,32,
""
);
file_gif_save(RUN_NONINTERACTIVE,
$img
,-1,
$path
,
$path
,1,0,0,0)
unless
$example
;
}
sub
Create_Image {
my
(
$text
,
$size
)=
@_
;
my
(
$Image
,
$Text_Layer
,
$Background_Layer
,
$Width
,
$Height
);
$border
= 10;
$size
= 100;
$Background_Colour
=
$white
;
$Text_Colour
=
$black
;
$Image
= gimp_image_new(256,256,RGB);
$Text_Layer
= gimp_text(
$Image
,-1,0,0,
$text
,
$border
,1,
$size
,PIXELS,
"*"
,
$font
,
"*"
,
"*"
,
"*"
,
"*"
);
gimp_palette_set_background(
$Text_Colour
);
gimp_layer_set_preserve_trans(
$Text_Layer
, TRUE);
$Width
= gimp_drawable_width(
$Text_Layer
);
$Height
= gimp_drawable_height(
$Text_Layer
);
$Background_Layer
= gimp_layer_new(
$Image
,
$Width
,
$Height
,RGB_IMAGE,
"Background"
,100,NORMAL_MODE);
gimp_image_resize(
$Image
,
$Width
,
$Height
,0,0);
gimp_image_add_layer(
$Image
,
$Background_Layer
, 1);
gimp_palette_set_background(
$Background_Colour
);
gimp_drawable_fill(
$Background_Layer
,BG_IMAGE_FILL);
gimp_display_new (
$Image
)
if
$example
;
}
sub
extension_create_images {
$Image_Directory
=
"/tmp"
;
$active
= 0;
open
(IMAGE_LIST,
"/tmp/image_list"
);
while
( <IMAGE_LIST> ) {
chop
;
Create_Image (
split
(/\|/));
}
}
sub
query {
gimp_install_procedure(
"extension_create_images"
,
"a test extension in perl"
,
"try it out"
,
"Marc Lehmann"
,
"Marc Lehmann"
,
"1997-02-06"
,
"<Toolbox>/Xtns/Create_Images"
,
"*"
, PROC_EXTENSION,
[[PARAM_INT32,
"run_mode"
,
"Interactive, [non-interactive]"
]], []);
}
sub
net {
extension_create_images;
}
exit
gimp_main;