genimages.pl from gzz at Krugle
Show genimages.pl syntax highlighted
#!/usr/bin/perl
#
# Copyright (c) 2003, Tuomas J. Lukka
#
# This file is part of Gzz.
#
# Gzz is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Gzz 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 Lesser General
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with Gzz; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
@resolutions = (300, 170, 50);
@not = qw/
0000000008000000E951C69F2500047B509B19C36307791FF5813EE8F1C5DF461505ED93327A9F
0000000008000000E951C8305800044FD3E704860499CD06AC4FEF6B8B0232FEAC9548908CD189
/;
$not = join '|', @not;
for $file (<../Z/*>,<../Z-private/*>) {
$head = `head -10 $file `;
push @pdf, $file if $head =~ "Content-Type: application/pdf";
push @ps, $file if $head =~ "Content-Type: application/postscript";
push @png, $file if $head =~ "Content-Type: image/png";
}
print "PDF: ", join ' ',@pdf, "\n";
$mstmpimg = "../mstmpimg/";
# system "rm -rf $mstmpimg";
system "mkdir $mstmpimg";
system "mkdir $mstmpimg/tmp";
sub psystem($) {
print "RUNNING: $_[0]\n";
system($_[0]);
}
for $file (grep {!/$not/} @png) {
$file =~ /b_(\w+)$/ or die "Invalid block name $file";
$block = $1;
$resultname = $block;
psystem "perl stripblock.pl $file >$mstmpimg/$resultname";
}
for $resolution (@resolutions) {
for $file (grep {!/$not/} @pdf) {
$file =~ /b_(\w+)$/ or die "Invalid block name $file";
$block = $1;
# First, do into triple resolution
$tres = $resolution ;
if(!$do_all) {
if(-e "$mstmpimg/$block-$resolution-1") {
print "Ignoring existing: $block\n";
next;
}
}
$tmpfile = "$mstmpimg/tmp/$block-tmp";
system "perl stripblock.pl $file >$tmpfile";
psystem "(cd ../mstmpimg/tmp; gs -dBATCH -dNOPAUSE -sDEVICE=png256 -r$tres -sOutputFile=$block-$resolution-%d $block-tmp) ";
# for $image (<$mstmpimg/tmp/$block-tmp-$resolution-*.ppm>) {
# $to = $image;
# $to =~ s/-tmp-/-/;
# $to =~ s/\.ppm//;
# } else {
# system "pnmtopng $image >$to";
# }
# unlink $image;
# }
system "mv $mstmpimg/tmp/$block* $mstmpimg/";
unlink $tmpfile;
}
}
See more files for this project here