Hallo zusammen,
ich habe im Anhang ein Skript die mir Vektor in PNG wandelt.
Klappr super.
Irgendwie weiss ich aber gerade nicht wo ich da
die Anweisung reingebe, das er mit das Original.eps löscht.
Kann mir da jemand helfen?
#!var/run/runperl -w
# $Id: eps2png.pl,v 1 2016/01/25 dhe 14:12:03 tom Exp $
#
# Sample configuration
#
my $default_settings = <<'</SETTINGS>'; # Let Perl ignore the settings block
<SETTINGS>
<General
Enable="true"
Hot_Folder="/demovol/eps2jpeg"
Include_Subdirectories="false"
User=""
Timeout=""
/>
<File_Types
Types="EPSF"
Suffixes="eps"
Folder_Changes="false"
/>
<Environment
OUTDIR="DONE"
MAXWIDTH="500"
MAXHEIGHT="500"
/>
</SETTINGS>
use strict;
BEGIN {
use vars qw($HELIOSDIR);
$HELIOSDIR = $ENV{"HELIOSDIR"} or die "HELIOSDIR not set in environment\n";
unshift(@INC, "$HELIOSDIR/etc/perl");
}
use HELIOS::Utils;
use File::Basename;
use IO::Handle;
STDERR->autoflush(1); # Write data immediately to fd
my $scriptdebug = int ($ENV{SCRIPTDEBUG} || "0");
my $maxwidth = int ($ENV{MAXWIDTH} || "500");
my $maxheight = int ($ENV{MAXHEIGHT} || "500");
my $outdir = $ENV{OUTDIR} || die "$0: directory not defined\n";
my $file = $ARGV[0] || die "$0: no input file specified\n";
print "Start Script: $0 $file\n" if ($scriptdebug > 0);
my $dir = (dirname $file)."/";
my $filename = basename $file;
(my $newbase = $filename) =~ s/\.\w*$//;
# create output directory and move the file into it
system("$HELIOSDIR/bin/dt", "mkdir", "$dir$outdir") if not stat("$dir$outdir");
system("$HELIOSDIR/bin/dt", "mv", "$file", "$dir$outdir");
# go to output directory
my $workdir = HELIOSPathToSystemPath("$dir$outdir");
chdir($workdir);
my $x = 0;
my $y = 0;
my $xshift = 0;
my $yshift = 0;
my $res = 72;
my $GotBox = 0;
# get the BoundingBox from the EPSF
open(FD, "<$filename");
while(<FD>) {
my $line = $_;
# try to get the HiResBoundingBox...
if($line =~ /%%HiResBoundingBox: (\d+.\d+) (\d+.\d+) (\d+.\d+) (\d+.\d+)/) {
print "HiResBoundingBox: llx: $1\tlly: $2\turx: $3\tury: $4\n" if ($scriptdebug > 0);
$xshift = $1/72; # the shift value unit is inch not pixel
$yshift = $2/72;
$x = $3-$1;
$y = $4-$2;
last;
}
# ... but use the BoundingBox when it it not available.
next if $GotBox;
if ($line =~ /%%BoundingBox: (\d+) (\d+) (\d+) (\d+)/) {
print "BoundingBox: llx: $1\tlly: $2\turx: $3\tury: $4\n" if ($scriptdebug > 0);
$xshift = $1/72; # the shift value unit is inch not pixel
$yshift = $2/72;
$x = $3-$1;
$y = $4-$2;
$GotBox = 1;
}
}
close(FD);
if($x eq 0 || $y eq 0) { die "Sorry, no suitable bounding box found\n"; }
print "Image size: x: $x\ty: $y\txshift: $xshift\tyshift: $yshift\n" if ($scriptdebug > 0);
# calculate a new resolution to get an image with specified dimensions
# check x and y pixels and calculate new x and y
if($x > $maxwidth) { # if x is more than specified max value
my $scale = $maxwidth/$x; # factor ($scaling times higher than $maxwidth)
$res *= $scale; # the new resolution
$x *= $scale; # recalculate $x and $y
$y *= $scale;
print "x is greater than $maxwidth px - new x: $x; new y: $y; new resolution: $res (scaling=$scale)\n" if ($scriptdebug > 0);
}
if($y > $maxheight) { # same as above, but using y now
my $scale = $maxheight/$y;
$res *= $scale;
$x *= $scale;
$y *= $scale;
print "y is greater than $maxheight px - new x: $x; new y: $y; new resolution: $res (scaling=$scale)\n" if ($scriptdebug > 0);
}
$xshift = -$xshift;
# run 'psrip' zum erzeugen eines Temporaeren TIff ...
print STDERR "Status: Running 'psrip' for file $file\n";
my @cmd = ("$HELIOSDIR/bin/psrip");
push @cmd, "-A";
push @cmd, "-T";
push @cmd, "-l 3";
push @cmd, "-s $xshift,$yshift";
push @cmd, "-e $x,$y";
push @cmd, "-oPrintResolution=$res";
push @cmd, "-oRasterImageType=TIFF";
push @cmd, "-oTransparencyMask=on";
push @cmd, ("-i", "$filename", "$newbase");
print "Cmd: ".(join " ",@cmd)."\n" if ($scriptdebug > 0);
system(@cmd);
# ... Konvertierung zum PNG Freigestellt
print STDERR "Status: Running 'layout' for file $newbase.1.tif\n";
@cmd = ("$HELIOSDIR/bin/layout");
push @cmd, "-v" if ($scriptdebug > 0);
push @cmd, "-oOmitProfile=True";
push @cmd, "-oSpotToProcess=True";
push @cmd, "-oPrintColor=RGB";
push @cmd, "-oyPix=200";
push @cmd, "-oxPix=200";
push @cmd, "-oPrintResolution=72";
push @cmd, ("-l", "$newbase.1.tif", "{unix,native,,PNGf}$newbase.png");
print "Cmd: ".(join " ",@cmd)."\n" if ($scriptdebug > 0);
system(@cmd);
# delete the temporary TIFF file
system("$HELIOSDIR/bin/dt", "rm", "$newbase.1.tif");
print "End Script: $0 $file\n" if ($scriptdebug > 0);