see plug-ins/perl/Changes

This commit is contained in:
Marc Lehmann 1999-11-20 02:20:27 +00:00
parent 6e18df3e0b
commit fc347b959c
5 changed files with 114 additions and 2 deletions

View File

@ -2,6 +2,8 @@ Revision history for Gimp-Perl extension.
1.16
- removed sethspin.pl & billboard, they are no longer maintained :(
- *sigh* removed some debugging code.
- new save-filter "dataurl" (more a joke, but it does work).
1.15 Fri Nov 19 19:12:16 CET 1999
- added italian translations by Daniele Medri (madrid@kjws.com).

View File

@ -353,7 +353,7 @@ sub quiet_die {
$in_top ? exit(1) : die "IGNORE THIS MESSAGE\n";
}
unless($no_SIG||1) {
unless($no_SIG) {
$SIG{__DIE__} = sub {
unless ($^S || !defined $^S || $in_quit) {
die_msg $_[0];

View File

@ -118,6 +118,7 @@ examples/povray
examples/avi
examples/layerfuncs
examples/bricks
examples/dataurl
pxgettext
po/gimp-perl.pot
po/de.po

View File

@ -35,7 +35,7 @@ if ($ARGV[0] ne "--writemakefile") {
repdup centerguide stampify goldenmean triangle mirrorsplit
layerfuncs randomart1 glowing_steel frame_reshuffle frame_filter
logulator miff gimpmagick guide_remove guides_to_selection burst
fire povray avi layerfuncs bricks
fire povray avi layerfuncs bricks dataurl
);
@pdl_pins =
qw(

109
plug-ins/perl/examples/dataurl Executable file
View File

@ -0,0 +1,109 @@
#!/usr/bin/perl
# pcg@goof.com
# this is not totally serious...
use Gimp;
use Gimp::Fu;
use Gimp::UI;
use Fcntl;
# Gimp::set_trace(TRACE_ALL);
sub encode_base64 ($;$)
{
my $res = "";
my $eol = $_[1];
$eol = "\n" unless defined $eol;
pos($_[0]) = 0; # ensure start at the beginning
while ($_[0] =~ /(.{1,45})/gs) {
$res .= substr(pack('u', $1), 1);
chop($res);
}
$res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs
# fix padding at the end
my $padding = (3 - length($_[0]) % 3) % 3;
$res =~ s/.{$padding}$/'=' x $padding/e if $padding;
# break encoded string into lines of no more than 76 characters each
if (length $eol) {
$res =~ s/(.{1,76})/$1$eol/g;
}
$res;
}
register "file_dataurl",
"saves the image as many small tiles using data:-urls",
"Uses data:-urls to save a html table with embedded image data",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"1999-11-20",
"<Save>/DATAURL",
"*",
[
[PF_SPINNER, "tile_x", "tile width", 32, [0, 128, 1, 1]],
[PF_SPINNER, "tile_y", "tile height", 32, [0, 128, 1, 1]],
],
sub {
my($img,$drawable,$filename,$filename2,$tx,$ty) = @_;
my($new_img,$new_drawable);
my $max;
my $export = Gimp::UI::export_image ($new_img=$img, $new_drawable=$drawable, "DATAURL",
CAN_HANDLE_INDEXED|CAN_HANDLE_ALPHA);
die "export failed" if $export == EXPORT_CANCEL;
my ($w,$h) = ($new_drawable->width, $new_drawable->height);
my $tmp = Gimp->temp_name(".gif");
sysopen FILE,$filename,O_CREAT|O_TRUNC|O_WRONLY or die "Unable to open '$filename' for writing: $!\n";
print FILE "<html><body>\n";
init Progress "Saving '$filename' as DATAURL...";
print FILE "<table width=$w cellspacing=0 cellpadding=0 border=0>";
for(my $y=0; $y<$h; $y+=$ty) {
my $wy = $h-$y < $ty ? $h-$y : $ty;
print FILE "<tr>";
for(my $x=0; $x<$w; $x+=$tx) {
my $wx = $w-$x < $tx ? $w-$x : $tx;
my $img = $new_img->channel_ops_duplicate;
$img->crop($wx,$wy,$x,$y);
($img->get_layers)[0]->file_gif_save(($tmp)x2, 0, 0, 0, 0);
#($img->get_layers)[0]->file_png_save(($tmp)x2, 0, 1, 9);
#($img->get_layers)[0]->file_jpeg_save(($tmp)x2, 0.5, 0, 1, 0, "", 0, 1, 0, 0);
$img->delete;
my $data = do {
local(*TEMP,$/);
open TEMP, "<$tmp" or die "Unable to read temporary image tile $tmp: $!";
<TEMP>;
};
unlink $tmp;
$url = "data:image/gif;base64,".(encode_base64 $data, "");
$max = length($url) if length($url) > $max;
print FILE "<td><img src=\"", $url, "\">";
update Progress (($y*$w+$x*$ty)/($w*$h));
}
}
print FILE "</table>\n";
print FILE "</html>\n";
close FILE;
warn "url size is too large ($max > 1024)\n" if $max > 1024;
$new_img->delete if $export == EXPORT_EXPORT;
();
};
Gimp::on_query {
Gimp->register_save_handler("file_dataurl_save", "dataurl", "");
};
exit main;