/usr/share/mapivi/PlugIns/Join-RGB is in mapivi 0.9.7-1.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #!/usr/bin/perl -w
# include perl packages
use strict;
use warnings;
use diagnostics;
use Tk;
use Tk::FileSelect;
use File::Basename;
my $nr = @ARGV;
if ($nr != 3) {
print "Error: $0 called with wrong number of arguments (should be 3).\n";
usage();
exit();
}
my $red = "";
my $green = "";
my $blue = "";
foreach (0 .. $nr-1) {
my $pic = $ARGV[$_];
if ($pic =~ m/.*red.*/i) { $red = $pic; }
if ($pic =~ m/.*green.*/i) { $green = $pic; }
if ($pic =~ m/.*blue.*/i) { $blue = $pic; }
}
if ($red eq "") {
print "$0 called with no red channel!\n";
usage();
exit();
}
if ($green eq "") {
print "$0 called with no green channel!\n";
usage();
exit();
}
if ($blue eq "") {
print "$0 called with no blue channel!\n";
usage();
exit();
}
my $dir = dirname($red);
if (!-d $dir) {
print "$dir is no valid directory\n";
usage();
exit();
}
my $top = MainWindow->new;
$top->title("MaPiVi Plugin RGB Seperator");
$top->Label(-text => "Create a",
)->pack();
$top->Button(-text => "RGB picture",
-command => sub { export(); })->pack();
$top->Label(-text => "picture of the three selected channel pictures",
)->pack();
$top->Button(-text => "exit plugin", -command => \&exit)->pack();
$top->MainLoop;
sub export {
my $rgb = $red;
$rgb =~ s/(.*)(red)(\.jp(g|eg))/$1RGB$3/i;
print "rgb outoput file = $rgb\n";
if (-f "$rgb") {
my $rc = $top->messageBox(-icon => 'warning', -message => "output file $rgb exist. Ok to overwrite?",
-title => "Plugin", -type => "OKCancel");
return if ($rc !~ m/Ok/i);
}
if (-f "$rgb.ppm") {
my $rc = $top->messageBox(-icon => 'warning', -message => "temp file $rgb.ppm exist. Ok to overwrite?",
-title => "Plugin", -type => "OKCancel");
return if ($rc !~ m/Ok/i);
}
my $command = "composite -compose copyred $red $green $rgb.ppm";
(system "$command") == 0 or print "Error: $command failed: $!\n";
$command = "composite -quality 95 -compose copyblue $blue $rgb.ppm $rgb";
(system "$command") == 0 or print "Error: $command failed: $!\n";
if (-f "$rgb.ppm") {
if ( unlink("$rgb.ppm") != 1) { # unlink returns the number of successfull removed files
$top->messageBox(-icon => 'warning', -message => "Could not delete file \"$rgb.ppm\": $!",
-title => "Error", -type => "OK");
print "Plugin $0 finished with errors!\n";
exit();
}
}
print "Plugin $0 finished successfully!\n";
exit();
}
##############################################################
# usage
##############################################################
sub usage {
my $prog = basename($0);
print "\nUsage: $prog file1-Red.jpg file2-Green.jpg file3-Blue.jpg\n\n";
print "This is a plugin for mapivi (see http://mapivi.de.vu)\n";
print "It will join the three selected RGB channel pictures from mapivi\n";
print "into one RGB picture\n";
print "The file names must include the corresponding color\n";
print "(red, green, blue; in upper or lower case)\n";
print "Author: Martin Herrmann <martin-herrmann\@gmx.de>\n";
print "License: GNU General Public License, version 2\n";
}
# Tell Emacs that this is really a perl script
# Local Variables:
# mode:perl
# End:
|