see plug-ins/perl/Changes

This commit is contained in:
Marc Lehmann 1999-11-08 20:06:21 +00:00
parent 1efdbb0eee
commit 9e274a7164
11 changed files with 424 additions and 283 deletions

View File

@ -7,6 +7,8 @@ Revision history for Gimp-Perl extension.
- (some) changes for the gimp api renaming.
- added export capabilities to miff/avi.
- fixed "dirty" identifier clash with <= 5.005_03 && PERL_POLLUTE.
- updated seth's scripts.
- improved avi hunk skipping and 24 bit handling.
1.14 Mon Oct 11 03:23:13 CEST 1999
- set the version of all modules explicitly (for the benefit of CPAN).

View File

@ -281,3 +281,26 @@ convert_15_24_inplace (datasv)
OUTPUT:
datasv
void
convert_bgr_rgb_inplace (datasv)
SV * datasv
CODE:
char *data, *end;
data = SvPV_nolen (datasv);
end = SvEND (datasv);
while (data < end)
{
char x = data[0];
data[0] = data[2];
data[2] = x;
data += 3;
}
OUTPUT:
datasv

View File

@ -102,7 +102,6 @@ examples/goldenmean
examples/triangle
examples/billboard
examples/mirrorsplit
examples/oneliners
examples/randomart1
examples/colourtoalpha
examples/pixelmap

View File

@ -5,7 +5,7 @@ use Config;
$|=1;
@examples =
qw(windy.pl prep4gif.pl webify.pl PDB tex-to-float ditherize.pl
qw(windify.pl prep4gif.pl webify.pl PDB tex-to-float ditherize.pl
border.pl view3d.pl feedback.pl xachlego.pl xachshadow.pl parasite-editor
scratches.pl blowinout.pl terral_text xachvision.pl perlcc gouge
sethspin.pl animate_cells image_tile yinyang stamps font_table

View File

@ -1,63 +1,114 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
#!/usr/bin/perl
<!--
use Gimp qw( :auto );
use Gimp::Fu;
Available WWWOFFLE Variables (all with a '$' prefix).
# alpha2color.pl
# by Seth Burgess <sjburges@gimp.org>
# Version 0.02
# Oct 16th, 1998
#
# This script simply changes the current alpha channel to a given color
# instead. I'm writing it primarily for use with the displace plugin,
# but I imagine it'll have other uses.
localhost = The hostname of the server running wwwoffled (='localhost:8080').
url = The URL that was asked for (='http://www.gimp.org/%7Esjburges/alpha2color.pl').
already = A flag to indicate that the page is already cached (='').
password = A one-time password to allow cancellation of the page (='0U3T7nn1gRTCe8Y3QkMQOg').
# TODO: Selection is currently ignored. It'd be better if it remembered
# what the previous selection was.
# Also, it needs to find a happier home than in the Filters/Misc menu.
-->
# Gimp::set_trace(TRACE_ALL);
<HEAD>
<TITLE>WWWOFFLE - Will Get http://www.gimp.org/%7Esjburges/alpha2color.pl</TITLE>
</HEAD>
# Revision History
# v0.02 - fixed up @color (should be $color) and undef; (should be return();)
<BODY>
sub save_layers_state ($) {
$img = shift;
my @layers = $img->get_layers;
$i = 0;
foreach $lay (@layers) {
if ($lay->get_visible){
$arr[$i] = 1;
}
else {
$arr[$i] = 0;
}
$i++;
}
return @arr;
}
<!-- Standard WWWOFFLE Message Page Top Banner -->
sub restore_layers_state($@) {
$img = shift;
@arr = @_;
my @layers = $img->get_layers;
$i = 0;
foreach $lay (@layers) {
$lay->set_visible($arr[$i]);
$i++;
}
}
<p align=center>
<b>WWWOFFLE</b> - <b>W</b>orld <b>W</b>ide <b>W</b>eb <b>Offl</b>ine <b>E</b>xplorer
</p>
sub alpha2col {
my ($img, $drawable, $color) = @_;
<hr>
my $oldcolor = gimp_palette_get_background();
<!-- Standard WWWOFFLE Message Page Top Banner -->
my @layers = gimp_image_get_layers($img);
<H1 align=center>WWWOFFLE Request Recorded</H1>
# if there's not enough layers, abort.
if ($#layers < 0) {
gimp_message("You need at least 1 layer to perform alpha2color!");
print "Only ", scalar(@layers), " layers found!(", $layers[0],")\n";
return 0;
}
<p align=center>
Your request for URL
<br>
<b><tt>http://www.gimp.org/%7Esjburges/alpha2color.pl</tt></b>
<br>
has been recorded for download.
</p>
# Hide the bottom layer, so it doesn't get into the merge visible later.
<!--
@layer_visibilities = save_layers_state ($img);
# foreach $visible (@layer_visibilities) {
# print $visible, "\n";
# }
$target_layer = gimp_image_get_active_layer($img);
@offsets=$target_layer->offsets;
# print $target_layer, "\n";
foreach $eachlay (@layers) {
$eachlay->set_visible(0);
}
$target_layer->set_visible(1);
gimp_palette_set_background($color);
$newlay = $target_layer->copy(1);
$img->add_layer($newlay, 0);
$newlay->set_offsets(@offsets);
$target_layer->set_active_layer;
Useful WWWOFFLE Buttons
$img->selection_all;
$target_layer->edit_fill;
$img->selection_none;
-->
$foreground = gimp_image_merge_visible_layers($img,0);
restore_layers_state($img, @layer_visibilities);
gimp_palette_set_background($oldcolor);
gimp_displays_flush();
return();
}
<p align=center>
[<a href="http://localhost:8080/control/delete-req/password=0U3T7nn1gRTCe8Y3QkMQOg?http://www.gimp.org/%7Esjburges/alpha2color.pl">Cancel</a>|Refresh:<a href="http://localhost:8080/refresh-options/?http://www.gimp.org/%7Esjburges/alpha2color.pl">Options</a>|<a href="http://localhost:8080/monitor-options/?http://www.gimp.org/%7Esjburges/alpha2color.pl">Monitor</a>|<a href="http://localhost:8080/index/url/?http://www.gimp.org/%7Esjburges/alpha2color.pl">Index</a>]
</p>
register
"plug_in_alpha2color",
"Alpha 2 Color",
"Change the current alpha to a selected color.",
"Seth Burgess",
"Seth Burgess<sjburges\@gimp.org>",
"2-15-98",
"<Image>/Image/Colors/Alpha2Color",
"RGBA",
[
[PF_COLOR, "color", "Color for current alpha", [127,127,127]]
],
\&alpha2col;
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
exit main;
<hr>
<p align=center>
WWWOFFLE - [<a href="http://localhost:8080/Welcome.html">Welcome Page</a>|<a href="http://localhost:8080/FAQ.html">FAQ</a>] - WWWOFFLE
</p>
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
</BODY>
</HTML>

View File

@ -29,7 +29,7 @@ register "file_avi_save",
"Saves images in the 24 bit uncompressed AVI format used by windows software",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"1999-10-26",
"1999-11-08",
"<Save>/AVI",
"RGB",
[
@ -122,6 +122,7 @@ register "file_avi_save",
my $d = $r->get_rect2(0,0,$width,$height);
Gimp::RAW::convert_32_24_inplace $d if $r->bpp == 4;
Gimp::RAW::reverse_v_inplace $d, $width*3;
Gimp::RAW::convert_bgr_rgb_inplace $d if $depth == 24;
Gimp::RAW::convert_24_15_inplace $d if $depth == 16;
$idx1 .= "00db" . pack "V*", 16, tell FILE, $framesize if $index;
@ -177,10 +178,10 @@ sub skip_hunk {
register "file_avi_load",
"load uncompressed avi movie",
"Loads images that were saved in 24 bit uncompressed RGB AVI format used mainly by windows",
"Loads images that were saved in 15/24 bit uncompressed RGB AVI format used mainly by windows",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"1999-09-14",
"1999-11-08",
"<Load>/AVI",
undef,
[],
@ -248,6 +249,7 @@ register "file_avi_load",
100,NORMAL_MODE);
Gimp::RAW::convert_15_24_inplace $comment if $depth == 16;
Gimp::RAW::convert_bgr_rgb_inplace $comment if $depth == 24;
Gimp::RAW::reverse_v_inplace $comment,$width*3;
(new PixelRgn $layer,0,0,$width,$height,1,0)->set_rect2($comment,0,0);
$layer->add_layer(0);
@ -257,8 +259,12 @@ register "file_avi_load",
"00dc" => sub { die "compressed data not handled\n" },
"01wb" => \&skip_hunk, # audio data
"idx1" => \&skip_hunk, # hunk index
"ISFT" => \&skip_hunk, # i? software?
"ICOP" => \&skip_hunk, # i? copyright?
"IDIT" => \&skip_hunk, # i? time stamp??
sub {
warn "skipping hunk (@_), please report!\n";
skip_hunk $_[1];
}
);

View File

@ -1,63 +1,189 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
#!/usr/bin/perl -w
<!--
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
Available WWWOFFLE Variables (all with a '$' prefix).
# This one's all mine. Well, its GPL/Artisitic but I"m the author and creator. # I think you need gimp 1.1 or better for this - if you don't, please let
# me know
localhost = The hostname of the server running wwwoffled (='localhost:8080').
url = The URL that was asked for (='http://www.gimp.org/%7Esjburges/billboard').
already = A flag to indicate that the page is already cached (='').
password = A one-time password to allow cancellation of the page (='G2HohImsZPA9Rmi3igNl5Q').
# I'm hacking this on top of my sethspin script, so this is doing even more
# stuff it wasn't really designed to do. Hence if you thought sethspin was
# a bit ugly, look at this one...
-->
# I think it was tigert that suggested this. It turned out to be less
# complex than I orginally thought so I figured I'd give it a spin.
# Seth Burgess
# <sjburges@gimp.org>
<HEAD>
<TITLE>WWWOFFLE - Will Get http://www.gimp.org/%7Esjburges/billboard</TITLE>
</HEAD>
use Gimp qw(:auto);
use Gimp::Fu;
use Gimp::Util;
<BODY>
# Uncomment below to spew forth much data about whats going on.
#Gimp::set_trace(TRACE_ALL);
<!-- Standard WWWOFFLE Message Page Top Banner -->
sub saw { # a sawtooth function on PI
($val) = @_;
if ($val < 3.14159/2.0) {
return ($val/3.14159) ;
}
elsif ($val < 3.14159) {
return (-1+$val/3.14159);
}
elsif ($val < 3.14159+3.14159/2.0) {
return ($val/3.14159) ;
}
else {
return (-1+$val/3.14159);
}
}
<p align=center>
<b>WWWOFFLE</b> - <b>W</b>orld <b>W</b>ide <b>W</b>eb <b>Offl</b>ine <b>E</b>xplorer
</p>
sub spin_layer { # the function for actually spinning the layer
my ($img, $spin, $dest, $numframes, $prp, $blinds) = @_;
# Now lets spin it!
$stepsize = 3.14159/$numframes; # in radians
for ($i=0; $i<=3.14159; $i+=$stepsize) {
Gimp->progress_update ($i/3.14159);
# create a new layer for spinning
$framelay = ($i < 3.14159/2.0) ? $spin->copy(1) : $dest->copy(1);
$img->add_layer($framelay, 0);
# spin it a step
# Here I need to make the proper selection, repeatedly if necessary
$blindheight = $img->height/$blinds;
for ($j=0; $j<$blinds; $j++) {
# select a section
$img->rect_select(0, $j*$blindheight, $img->width, $blindheight, 2, 0, 0.13);
@x = $img->selection_bounds();
# x[1],x[2] x[3],x[2]
# x[1],x[4] x[3],x[4]
$floater = $framelay->perspective(1,
$x[1]+saw($i)*$prp*$framelay->width,$x[2]+$blindheight *sin($i)/2,
$x[3]-saw($i)*$prp*$framelay->width,$x[2]+$blindheight *sin($i)/2,
$x[1]-saw($i)*$prp*$framelay->width,$x[4]-$blindheight *sin($i)/2,
$x[3]+saw($i)*$prp*$framelay->width,$x[4]-$blindheight *sin($i)/2);
<hr>
# Gimp Perspective Functionality has changed. It used to create a floating
# selection if there was a selection active already. Now it only does that
# in interactive - PDB makes it a new layer. Fine by me, wish the docs had
# changed though.
# $floater->floating_sel_anchor;
<!-- Standard WWWOFFLE Message Page Top Banner -->
} # end for ($j=0;...
<H1 align=center>WWWOFFLE Request Recorded</H1>
# I need to create another layer beind this spun one now
$backlayer = $framelay->layer_copy(0);
$img->add_layer($backlayer, 1);
$backlayer->fill(1); # BG-IMAGE-FILL
}
for ($i=0; $i<$numframes; $i++) {
@all_layers = $img->get_layers();
$img->set_visible($all_layers[$i],$all_layers[$i+1]);
$img->merge_visible_layers(0);
}
@all_layers = $img->get_layers();
$destfram = $all_layers[$numframes]->copy(0);
$img->add_layer($destfram,0);
<p align=center>
Your request for URL
<br>
<b><tt>http://www.gimp.org/%7Esjburges/billboard</tt></b>
<br>
has been recorded for download.
</p>
# clean up my temporary layers
$img->remove_layer($all_layers[$numframes]);
$img->remove_layer($all_layers[$numframes+1]);
}
<!--
register "billboard",
"Billboard",
"Take one image. Spin it about the multiple axes, and end up with another image. I made it for easy web buttons, mostly because somebody suggested to me.",
"Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>",
"1.3",
__"<Toolbox>/Xtns/Animation/Billboard",
"*",
[
[PF_DRAWABLE, "source", "What drawable to spin from?"],
[PF_DRAWABLE, "destination","What drawable to spin to?"],
[PF_INT8, "frames", "How many frames to use?", 16],
[PF_COLOR, "background", "What color to use for background if not transparent", [0,0,0]],
[PF_SLIDER, "perspective", "How much perspective effect to get", 40, [0,255,5]],
[PF_TOGGLE, "spin_back", "Also spin back?" , 0],
[PF_TOGGLE, "convert_indexed", "Convert to indexed?", 1],
[PF_SPINNER, "billboard_slats", "Number of shades", 3, [1,50,1]],
],
[],
['gimp-1.1'],
sub {
my($src,$dest,$frames,$color,$psp,$spinback,$indexed, $shadenum) =@_;
$maxwide = ($src->width > $dest->width) ? $src->width : $dest->width;
$maxhigh = ($src->height > $dest->height) ? $src->height: $dest->height;
$img = gimp_image_new($maxwide, $maxhigh, RGB);
Useful WWWOFFLE Buttons
-->
$tmpimglayer = $img->add_new_layer(0,3,1);
$img->display_new;
Gimp->progress_init("Billboard...",-1);
$oldbackground = gimp_palette_get_background();
Palette->set_background($color);
$src->edit_copy();
$spinlayer = $tmpimglayer->edit_paste(1);
$spinlayer->floating_sel_to_layer();
<p align=center>
[<a href="http://localhost:8080/control/delete-req/password=G2HohImsZPA9Rmi3igNl5Q?http://www.gimp.org/%7Esjburges/billboard">Cancel</a>|Refresh:<a href="http://localhost:8080/refresh-options/?http://www.gimp.org/%7Esjburges/billboard">Options</a>|<a href="http://localhost:8080/monitor-options/?http://www.gimp.org/%7Esjburges/billboard">Monitor</a>|<a href="http://localhost:8080/index/url/?http://www.gimp.org/%7Esjburges/billboard">Index</a>]
</p>
$dest->edit_copy();
$destlayer = $tmpimglayer->edit_paste(1);
$destlayer->floating_sel_to_layer();
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
$tmpimglayer->remove_layer;
<hr>
$spinlayer->resize($maxwide, $maxhigh, $spinlayer->offsets);
$destlayer->resize($maxwide, $maxhigh, $destlayer->offsets);
# work around for PF_SLIDER when < 1
$psp = $psp/255.0;
<p align=center>
WWWOFFLE - [<a href="http://localhost:8080/Welcome.html">Welcome Page</a>|<a href="http://localhost:8080/FAQ.html">FAQ</a>] - WWWOFFLE
</p>
# need an even number of frames for spinback
if ($frames%2 && $spinback) {
$frames++;
gimp_message("An even number of frames is needed for spin back.\nAdjusted frames up to $frames");
}
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
spin_layer($img, $spinlayer, $destlayer, $spinback ? $frames/2 : $frames-1, $psp, $shadenum);
$img->set_visible($img->add_new_layer(1),($img->get_layers)[0]);
$img->merge_visible_layers(0);
if ($spinback) {
@layerlist = $img->get_layers();
$img->add_layer($layerlist[$frames/2]->copy(0),0);
@layerlist = $img->get_layers();
spin_layer($img, $layerlist[1], $layerlist[0], $frames/2, $psp, $shadenum);
$img->remove_layer(($img->get_layers)[0]);
}
# unhide and name layers
@all_layers = $img->get_layers;
$img->set_visible(@all_layers);
for ($i=1; $i<=$frames ; $i++) {
$all_layers[$i-1]->set_name("Spin Layer $i (50ms)");
}
$all_layers[$frames-1]->set_name("Spin Layer SRC (250ms)");
if ($spinback) {
$all_layers[$frames/2-1]->set_name("Spin Layer DEST (250ms)");
}
else { $all_layers[0]->set_name("Spin Layer DEST (250ms)")}
</BODY>
# indexed conversion wants a display for some reason
if ($indexed) {
$img->convert_indexed(1, # dither type = fs
MAKE_PALETTE, # palette type
255, # number of colors
0, # don't dither transparency
1, # (ignored)
"Custom" # custom palette name
);
}
Palette->set_background($oldbackground);
gimp_displays_flush();
return();
};
exit main;
</HTML>

View File

@ -1,63 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
#!/usr/bin/perl
<!--
# Revision 1.0: Released it
# 1.1: Marc Lehman added undo capability! <pcg@goof.com>
# 1.2: Added my email, and put it in "Noise" where it belongs
# <sjburges@gimp.org>
Available WWWOFFLE Variables (all with a '$' prefix).
localhost = The hostname of the server running wwwoffled (='localhost:8080').
url = The URL that was asked for (='http://www.gimp.org/%7Esjburges/feedback.pl').
already = A flag to indicate that the page is already cached (='').
password = A one-time password to allow cancellation of the page (='Bw7RTyicLuhCFPIb6HarMg').
use Gimp;
use Gimp::Fu;
-->
register "feedback",
"Take an image and feed it back onto itself multiple times",
"This plug-in simulates video feedback. It makes for kinda a neat desktop if you're into that sort of thing",
"Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>",
"2-15-99",
"<Image>/Filters/Noise/Feedback",
"RGB, GRAY",
[
[PF_SLIDER, "offset", "the amount the frames will offset", 3, [0, 255, 1]],
[PF_SLIDER, "repeat", "the number of times to repeat the illusion", 3, [0, 100, 1]],
],
sub {
my($img,$drawable,$offset,$repeat)=@_;
eval { $img->undo_push_group_start };
for (; $repeat>0; $repeat--) {
$drawable = $img->flatten;
$copylayer = $drawable->copy(1);
$img->add_layer($copylayer,0);
$copylayer->scale($img->width - $offset, $img->height - $offset, 0);
}
$img->flatten;
eval { $img->undo_push_group_end };
return();
};
<HEAD>
<TITLE>WWWOFFLE - Will Get http://www.gimp.org/%7Esjburges/feedback.pl</TITLE>
</HEAD>
exit main;
<BODY>
<!-- Standard WWWOFFLE Message Page Top Banner -->
<p align=center>
<b>WWWOFFLE</b> - <b>W</b>orld <b>W</b>ide <b>W</b>eb <b>Offl</b>ine <b>E</b>xplorer
</p>
<hr>
<!-- Standard WWWOFFLE Message Page Top Banner -->
<H1 align=center>WWWOFFLE Request Recorded</H1>
<p align=center>
Your request for URL
<br>
<b><tt>http://www.gimp.org/%7Esjburges/feedback.pl</tt></b>
<br>
has been recorded for download.
</p>
<!--
Useful WWWOFFLE Buttons
-->
<p align=center>
[<a href="http://localhost:8080/control/delete-req/password=Bw7RTyicLuhCFPIb6HarMg?http://www.gimp.org/%7Esjburges/feedback.pl">Cancel</a>|Refresh:<a href="http://localhost:8080/refresh-options/?http://www.gimp.org/%7Esjburges/feedback.pl">Options</a>|<a href="http://localhost:8080/monitor-options/?http://www.gimp.org/%7Esjburges/feedback.pl">Monitor</a>|<a href="http://localhost:8080/index/url/?http://www.gimp.org/%7Esjburges/feedback.pl">Index</a>]
</p>
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
<hr>
<p align=center>
WWWOFFLE - [<a href="http://localhost:8080/Welcome.html">Welcome Page</a>|<a href="http://localhost:8080/FAQ.html">FAQ</a>] - WWWOFFLE
</p>
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
</BODY>
</HTML>

View File

@ -1,31 +0,0 @@
#!/usr/bin/perl
use Gimp;
use Gimp::Fu;
use Gimp::Util;
# These are a couple of one-liners that you might find handy. Both should
# be undoable w/o any special magick, and work with any gimp.
# <sjburges@gimp.org>
register "layer_to_image_size", "Layer2ImageSize", "Expands layer to image size",
"Seth Burgess", "Seth Burgess <sjburges\@gimp.org>", "1.0",
__"<Image>/Layers/Layer to Image Size", "RGB*, GRAY*", [ ], sub {
($img, $layer) = @_;
$layer->resize($img->width, $img->height, $layer->offsets);
();
};
# <sjburges@gimp.org>
register "center_layer", "Center Layer",
"Centers the current layer on the image",
"Seth Burgess", "Seth Burgess <sjburges\@gimp.org>",
"1.0", __"<Image>/Layers/Center Layer", "RGB*, GRAY*", [], sub {
($img, $layer) = @_;
$layer->set_offsets(($img->width - $layer->width )/2,
($img->height - $layer->height)/2);
();
};
exit main;

View File

@ -1,63 +1,113 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
#!/usr/bin/perl
<!--
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
Available WWWOFFLE Variables (all with a '$' prefix).
use Gimp qw(:auto);
use Gimp::Fu;
localhost = The hostname of the server running wwwoffled (='localhost:8080').
url = The URL that was asked for (='http://www.gimp.org/%7Esjburges/prep4gif.pl').
already = A flag to indicate that the page is already cached (='').
password = A one-time password to allow cancellation of the page (='FgfIgpz3-IuS8wu+dVHeMw').
# This script requires a Gimp version >= 0.96 (I haven't checked - ymmv)
# small changes by Marc Lehmann <pcg@goof.com>
-->
# prep4gif.pl
# by Seth Burgess <sjburges@gimp.org>
# June 29, 1998
#
# This perl plug-in prepares a multilayer RGB image for use as a
# transparent gif. To use this prpoerly, you want to have something
# close to the intended background as the bottom layer. If convert
# to indexed is not selected, the bottom two options are unused.
#
# TODO: Write a nicer GUI than Gimp::Fu provides (learn some gtk)
# Anything else that seems useful
<HEAD>
<TITLE>WWWOFFLE - Will Get http://www.gimp.org/%7Esjburges/prep4gif.pl</TITLE>
</HEAD>
# Gimp::set_trace(TRACE_ALL);
<BODY>
sub prep {
my ($img, $drawable, $threshold, $growth, $index, $dither, $colors) = @_;
<!-- Standard WWWOFFLE Message Page Top Banner -->
# Duplicate this image, and work on the duplicate for the rest of the
# procedure.
my $out = gimp_channel_ops_duplicate($img);
<p align=center>
<b>WWWOFFLE</b> - <b>W</b>orld <b>W</b>ide <b>W</b>eb <b>Offl</b>ine <b>E</b>xplorer
</p>
# @layers is the ordered list, from top to bottom, of all layers in the
# duplicated image. To find length of the list, use $#layers
my @layers = gimp_image_get_layers($out);
<hr>
# if there's not enough layers, abort.
if ($#layers <= 0) {
gimp_message("You need at least 2 layers to perform prep4gif");
print "Only ", scalar(@layers), " layers found!(", $layers[0],")\n";
return;
}
<!-- Standard WWWOFFLE Message Page Top Banner -->
# Show the image early - this makes debugging a breeze
my $newdisplay = gimp_display_new($out);
<H1 align=center>WWWOFFLE Request Recorded</H1>
# Hide the bottom layer, so it doesn't get into the merge visible later.
<p align=center>
Your request for URL
<br>
<b><tt>http://www.gimp.org/%7Esjburges/prep4gif.pl</tt></b>
<br>
has been recorded for download.
</p>
my $bottomlayer = $layers[$#layers];
gimp_layer_set_visible($bottomlayer, 0);
gimp_layer_add_alpha($bottomlayer);
<!--
# NOTE TO PERL NEWBIES - 'my' variables should be declared in their outermost
# scope - if defined inside the if statement, will disappear to program.
Useful WWWOFFLE Buttons
my $foreground;
-->
if ($#layers > 1) {
$foreground = gimp_image_merge_visible_layers($out, 0);
}
else {
$foreground = $layers[0];
};
<p align=center>
[<a href="http://localhost:8080/control/delete-req/password=FgfIgpz3-IuS8wu+dVHeMw?http://www.gimp.org/%7Esjburges/prep4gif.pl">Cancel</a>|Refresh:<a href="http://localhost:8080/refresh-options/?http://www.gimp.org/%7Esjburges/prep4gif.pl">Options</a>|<a href="http://localhost:8080/monitor-options/?http://www.gimp.org/%7Esjburges/prep4gif.pl">Monitor</a>|<a href="http://localhost:8080/index/url/?http://www.gimp.org/%7Esjburges/prep4gif.pl">Index</a>]
</p>
my $layer_mask = gimp_layer_create_mask($foreground,2);
gimp_image_add_layer_mask ($out, $foreground, $layer_mask);
gimp_threshold($layer_mask,$threshold,255);
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
# Transfer layer mask to selection, and grow the selection
gimp_selection_layer_alpha($foreground);
gimp_selection_grow($out,$growth);
<hr>
# Apply this selection to the background
gimp_layer_set_visible($bottomlayer, 1);
gimp_image_set_active_layer($out, $bottomlayer);
gimp_selection_invert($out);
gimp_edit_cut($bottomlayer);
<p align=center>
WWWOFFLE - [<a href="http://localhost:8080/Welcome.html">Welcome Page</a>|<a href="http://localhost:8080/FAQ.html">FAQ</a>] - WWWOFFLE
</p>
# Clean up after yourself
gimp_image_remove_layer_mask($out, $foreground, 1);
my $outlayer = gimp_image_merge_visible_layers($out,0);
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
# Convert to indexed
if ($index) {
gimp_convert_indexed($out,1, MAKE_PALETTE, $colors, $dither, 1, "");
}
</BODY>
# Show all the changes.
gimp_displays_flush();
();
}
register
"prep4gif",
"Prep for gif",
"Make the image a small-cut-out of the intended background, so your transparent text doesn't look blocky.",
"Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>",
"2-15-98",
__"<Image>/Filters/Misc/Prepare for GIF",
"RGB*",
[
[PF_INT32, "lower_threshold", "Lower Alpha Threshold", 64],
[PF_INT32, "growth", "How Much growth for safety ",1],
[PF_TOGGLE, "convert_to_indexed", "Convert Image to indexed", 0],
[PF_TOGGLE, "dither", "Floyd-Steinberg Dithering?", 1],
[PF_INT32, "colors", "Colors to quantize to", "255"],
],
\&prep;
exit main;
</HTML>

View File

@ -1,63 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<!--
Available WWWOFFLE Variables (all with a '$' prefix).
localhost = The hostname of the server running wwwoffled (='localhost:8080').
url = The URL that was asked for (='http://www.gimp.org/%7Esjburges/windify.pl').
already = A flag to indicate that the page is already cached (='').
password = A one-time password to allow cancellation of the page (='6L9yq7nTjK35y2i8H3peGw').
-->
<HEAD>
<TITLE>WWWOFFLE - Will Get http://www.gimp.org/%7Esjburges/windify.pl</TITLE>
</HEAD>
<BODY>
<!-- Standard WWWOFFLE Message Page Top Banner -->
<p align=center>
<b>WWWOFFLE</b> - <b>W</b>orld <b>W</b>ide <b>W</b>eb <b>Offl</b>ine <b>E</b>xplorer
</p>
<hr>
<!-- Standard WWWOFFLE Message Page Top Banner -->
<H1 align=center>WWWOFFLE Request Recorded</H1>
<p align=center>
Your request for URL
<br>
<b><tt>http://www.gimp.org/%7Esjburges/windify.pl</tt></b>
<br>
has been recorded for download.
</p>
<!--
Useful WWWOFFLE Buttons
-->
<p align=center>
[<a href="http://localhost:8080/control/delete-req/password=6L9yq7nTjK35y2i8H3peGw?http://www.gimp.org/%7Esjburges/windify.pl">Cancel</a>|Refresh:<a href="http://localhost:8080/refresh-options/?http://www.gimp.org/%7Esjburges/windify.pl">Options</a>|<a href="http://localhost:8080/monitor-options/?http://www.gimp.org/%7Esjburges/windify.pl">Monitor</a>|<a href="http://localhost:8080/index/url/?http://www.gimp.org/%7Esjburges/windify.pl">Index</a>]
</p>
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
<hr>
<p align=center>
WWWOFFLE - [<a href="http://localhost:8080/Welcome.html">Welcome Page</a>|<a href="http://localhost:8080/FAQ.html">FAQ</a>] - WWWOFFLE
</p>
<!-- Standard WWWOFFLE Message Page Bottom Buttons -->
</BODY>
</HTML>