see plug-ins/perl/Changes

This commit is contained in:
Marc Lehmann 1999-08-01 20:48:36 +00:00
parent 5d929fb51b
commit 9ef96aeabf

View file

@ -4,18 +4,31 @@
# this sort of thing. Personally I'll probably only run it to test and # this sort of thing. Personally I'll probably only run it to test and
# put up a demo image. # put up a demo image.
# Since updated a couple times by others, and intgrated by me:
#
# Bruce Miller (fixed to accomdate 1.1.x changes)
# Brendon and Wendy Humphrey <brendy@swipnet.se> (progress bar, nice comments)
#
# If you have more additions, etc please don't hesitate to send them in!
use Gimp; use Gimp;
use Gimp::Fu; use Gimp::Fu;
use Gimp::Util; use Gimp::Util;
# Uncomment if you want to see everything that's going on.
# Gimp::set_trace(TRACE_ALL); # Gimp::set_trace(TRACE_ALL);
sub get_vguides { # get back an ordered set of vertical guides #
# Generates an ordered list of all existing vertical guides.
#
sub get_vguides {
my ($img)=@_; my ($img)=@_;
$i=0; $i=0;
my @vguides; my @vguides;
while ($i=$img->find_next_guide($i)) { while ($i=$img->find_next_guide($i)) {
if ($img->get_guide_orientation($i) == ORIENTATION_VERTICAL){ if ($img->get_guide_orientation($i) == &Gimp::VERTICAL_GUIDE){
$keyval = sprintf("%4d", $img->get_guide_position($i)); $keyval = sprintf("%4d", $img->get_guide_position($i));
$vkeys{$keyval} = $i; $vkeys{$keyval} = $i;
} }
@ -27,12 +40,16 @@ sub get_vguides { # get back an ordered set of vertical guides
return @vguides; return @vguides;
} }
sub get_hguides { # get back an ordered set of horizontal guides #
# Generates an ordered list of all existing horizontal guides.
#
sub get_hguides {
my ($img)=@_; my ($img)=@_;
$i=0; $i=0;
my @hguides; my @hguides;
while ($i=$img->find_next_guide($i)) { while ($i=$img->find_next_guide($i)) {
if ($img->get_guide_orientation($i) == ORIENTATION_HORIZONTAL){ if ($img->get_guide_orientation($i) == &Gimp::HORIZONTAL_GUIDE){
$keyval = sprintf("%4d", $img->get_guide_position($i)); $keyval = sprintf("%4d", $img->get_guide_position($i));
$hkeys{$keyval} = $i; $hkeys{$keyval} = $i;
} }
@ -44,7 +61,11 @@ sub get_hguides { # get back an ordered set of horizontal guides
return @hguides; return @hguides;
} }
sub dosel { # do the selection #
# Duplicate, crop and save the image fragment.
#
sub dosel {
($img, $savepath, $imgpath, $imgbasename, $l,$r,$t,$b, $i,$j) = @_; ($img, $savepath, $imgpath, $imgbasename, $l,$r,$t,$b, $i,$j) = @_;
$filename =~ m/^(.*)\.[^\.]*$/ ; $filename =~ m/^(.*)\.[^\.]*$/ ;
$imgname = "$imgbasename-$i-$j.gif"; $imgname = "$imgbasename-$i-$j.gif";
@ -60,9 +81,14 @@ sub dosel { # do the selection
return "$imgpath$imgname"; # what I want printed in html return "$imgpath$imgname"; # what I want printed in html
} }
#
# HTML Table Generation Functions
#
sub html_table_start { sub html_table_start {
($fn,$cellpadding,$cellspacing,$border,$capatalize) = @_; ($fn,$cellpadding,$cellspacing,$border,$capatalize) = @_;
$str = $capatalize ? "<TABLE CELLSPACING=$cellspacing CELLPADDING=$cellpadding BORDER=$border>\n" : $str = $capatalize ?
"<TABLE CELLSPACING=$cellspacing CELLPADDING=$cellpadding BORDER=$border>\n" :
"<table cellspacing=$cellspacing cellpadding=$cellpadding border=$border>\n" ; "<table cellspacing=$cellspacing cellpadding=$cellpadding border=$border>\n" ;
print $fn $str; print $fn $str;
} }
@ -75,7 +101,8 @@ sub html_table_row_start {
sub html_table_entry { sub html_table_entry {
($fn, $imgname, $width, $height, $capatalize) = @_; ($fn, $imgname, $width, $height, $capatalize) = @_;
$str = $capatalize ? "\t\t<TD><IMG SRC=\"$imgname\" WIDTH=\"$width\"HEIGHT=\"$height\"></TD>\n" : $str = $capatalize ?
"\t\t<TD><IMG SRC=\"$imgname\" WIDTH=\"$width\"HEIGHT=\"$height\"></TD>\n" :
"\t\t<td><img src=\"$imgname\" width=\"$width\"height=\"$height\"></td>\n"; "\t\t<td><img src=\"$imgname\" width=\"$width\"height=\"$height\"></td>\n";
print $fn $str; print $fn $str;
} }
@ -106,8 +133,8 @@ register "perlotine",
"Add guides to an image. Then run this. It will cut along the guides, and give you the html to reassemble the resulting images.", "Add guides to an image. Then run this. It will cut along the guides, and give you the html to reassemble the resulting images.",
"Seth Burgess", "Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>", "Seth Burgess <sjburges\@gimp.org>",
"1999-07-30", "1999-03-19",
"<Image>/Image/Transforms/Perl-o-tine", "<Image>/Guides/Perl-o-tine",
"*", "*",
[ [
[PF_STRING, "save_path", "The path to export the HTML to",$ENV{HOME}], [PF_STRING, "save_path", "The path to export the HTML to",$ENV{HOME}],
@ -127,13 +154,26 @@ register "perlotine",
if (!(scalar(@vert) || scalar(@horz))) { if (!(scalar(@vert) || scalar(@horz))) {
die ("No horizontal or vertical guides found. Aborted."); die ("No horizontal or vertical guides found. Aborted.");
} }
#
# Progress Bar
#
gimp_progress_init("Perl-o-Tine");
$progress_increment = 1/(scalar(@horz) * scalar(@vert));
$progress = 0.0;
# (Debugging info for the guide functions)
# print @vert, " LEN = ", scalar(@vert), "\n"; # print @vert, " LEN = ", scalar(@vert), "\n";
# print @horz, " LEN = ", scalar(@horz), "\n"; # print @horz, " LEN = ", scalar(@horz), "\n";
# foreach $guide (@vert) { # foreach $guide (@vert) {
# print $img->get_guide_position($guide), "\n"; # print $img->get_guide_position($guide), "\n";
# } # }
#
# Correctly format paths and filenames
#
if (!($savepath=~ m,/$,)) { # add a trailing slash if its not on there if (!($savepath=~ m,/$,)) { # add a trailing slash if its not on there
$savepath = $savepath . "/"; $savepath = $savepath . "/";
} }
@ -143,6 +183,7 @@ register "perlotine",
} }
if (!$separate) { $imgpath = ""; } if (!$separate) { $imgpath = ""; }
# open HTML file for writing
open FILE, ">$savepath$htmlname" or die "Couldn't open $savepath$filename: $!\n"; open FILE, ">$savepath$htmlname" or die "Couldn't open $savepath$filename: $!\n";
$top=0; $top=0;
@ -156,6 +197,10 @@ register "perlotine",
$imgname = dosel($img, $savepath, $imgpath, $imgbasename, $left, $right, $top, $bot, $i, $j); $imgname = dosel($img, $savepath, $imgpath, $imgbasename, $left, $right, $top, $bot, $i, $j);
html_table_entry(\*FILE, $imgname, $right-$left, $bot-$top, $capatalize); html_table_entry(\*FILE, $imgname, $right-$left, $bot-$top, $capatalize);
$left = $right + $cellspacing; $left = $right + $cellspacing;
# Increment the progress bar
$progress += $progress_increment;
gimp_progress_update ($progress);
} }
html_table_row_end(\*FILE, $capatalize); html_table_row_end(\*FILE, $capatalize);
$top = $bot + $cellspacing; $top = $bot + $cellspacing;