This file is indexed.

/usr/bin/metapixel-prepare is in metapixel 1.0.2-7.4.

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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/perl

# metapixel-prepare --- prepare images for metapixeling.

# Copyright (C) 1999-2004 Mark Probst
# Copyright (C) 2004 Jake Di Toro
# Copyright (C) 2006 Stefan Soeffing

# Maintainer: Mark Probst <schani@complang.tuwien.ac.at>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, you can either send email to this
# program's maintainer or write to: The Free Software Foundation,
# Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.

use strict;

use Getopt::Long;
use File::Basename;
use IO::Handle;

sub disambiguate_filename {
    my $filename = shift;
    my $suffix = shift;

    return "$filename$suffix" if !-e "$filename$suffix";

    my $ctr = 1;

    while (-e "$filename.$ctr$suffix") {
	++$ctr;
    }

    return "$filename.$ctr$suffix";
}

sub usage {
    print STDERR "Usage: $0 [OPTION]... <srcdir> <destdir>

Prepares all images in <srcdir> for use as small images in
photomosaics. The scaled versions and the table file are
stored in <destdir>.

  --help             display this help and exit
  --width=WIDTH      specify width of small images
  --height=HEIGHT    specify height of small images
  -r, --recurse      recurse through directories
  --debug            print out debugging info
";
    exit(1);
}

my ($width, $height, $destdir) = split /\s+/, `metapixel --print-prepare-settings`;

my $do_recurse;
my $DEBUG;

if (!GetOptions("help", \&usage,
		"width=i", \$width,
		"height=i", \$height,
		"recurse|r", \$do_recurse,
		"debug", \$DEBUG)) {
    usage();
}

if (!$width || $width <= 0 || !$height || $height <= 0) {
    print "$0: Width and height of the prepared images must be specified.\n";
    exit(1);
}

my $opts = "--width=$width --height=$height";

if ($#ARGV != 0 && $#ARGV != 1) {
    usage();
}

my $srcdir = $ARGV[0];

$destdir = $ARGV[1] if $#ARGV > 0;

if (! -d $srcdir || ! -r $srcdir) {
    print "$0: Source directory $srcdir does not exist or is unreadable.\n";
    exit(1);
}

unless ($destdir) {
    print "$0: A destination directory must be specified.\n";
    exit(1);
}
if (! -d $destdir) {
    print "$0: Destination directory $destdir does not exist.\n";
    exit(1);
}

STDOUT->autoflush(1);

sub process_dir {
    my $pdir = shift;
    my $do_recurse = shift;

    print "Processing dir: $pdir\n" if $DEBUG;

    if (opendir DIR, $pdir)
    {
	my @files = grep !/^\.\.?$/, readdir DIR;

	closedir DIR;

	foreach my $filename (@files) {
	    my $fullname = "$pdir/$filename";

	    print "Testing file: $fullname\n" if $DEBUG;

	    while (-l $fullname) {
		print "Following symlink: $fullname\n" if $DEBUG;
		$fullname = readlink($fullname);
	    }

	    if (-f $fullname && -r $fullname) {
		my ($name, $path, $suffix) = fileparse($fullname);

		print "Processing: $fullname\n" if $DEBUG;

		my $thumbname = disambiguate_filename("$destdir/$name$suffix", ".png");
		
		`metapixel $opts --prepare "$fullname" "$thumbname" "$destdir/tables.mxt"`;
		if ($? != 0) {
		    print "Error running metapixel - skipping file $fullname\n"
		    }
		else
		{
		    print "." if !$DEBUG;
		}
	    }
	    elsif (-d $fullname && -r $fullname && $do_recurse) {
		process_dir($fullname, $do_recurse);
	    }
	}
    } else {
	print "Error: cannot open directory $pdir\n";
    }
}

process_dir($srcdir, $do_recurse);