sub bildberechnen { use Image::Magick; my ($ursprungsdatei,$neuerDateiName,$max_x,$max_y)=@_; unless (-e $ursprungsdatei){ return "Datei $ursprungsdatei existiert nicht!"; } unless($max_x > 10){ return "Maximalbreite '$max_x' zu gering!"; } unless($max_y > 10){ return "Maximalhöhe '$max_y' zu gering!"; } my $image = Image::Magick->new(); print "öffne Datei: $ursprungsdatei ".." Line: ".."
\n" if($config{'umgebung'} eq "test"); $image->Read($ursprungsdatei); my ($x,$y) = $image->Get("width","height"); print "davor: x : $x, y : $y ".." Line: ".."
\n" if($config{'umgebung'} eq "test"); my $z = 0; if ($x > $max_x) { $z = $max_x/$x*100; $z = $z."%"; $image->Scale($z); $z = int($z); ($x,$y) = $image->Get("width","height"); printf "zu breit, auf %s\% reduziert ($x,$y) ",$z if($config{'umgebung'} eq "test");; print ." Line: ".."
\n" if($config{'umgebung'} eq "test"); } if ($y > $max_y) { $z = $max_y/$y*100; $z = int($z); $z = $z."%"; $image->Scale($z); ($x,$y) = $image->Get("width","height"); #printf "zu hoch, auf %s\% reduziert ($x,$y)",$z; #print "
\n"; } #print "danach: x : $x, y : $y
\n"; my $zielbilddatei="$neuerDateiName"; $image->Write(filename => $zielbilddatei); return($x,$y); }