guacamayo has asked for the wisdom of the Perl Monks concerning the following question:
Hello @all!
How can I optimize this?
The script should read .tiff's, write a text at the top and write again to STDOUT.
until ImageToBlob () takes 0.10 ms,with ImageToBlob it takes up to 3 sec.
Thanks in advance!
#!/usr/bin/perl use strict; use warnings; use Image::Magick; use Data::Dumper; use POSIX; my $def = shift || '/var/www/html/error.tif'; my $uri = $ENV{'PATH_TRANSLATED'} || $def; my $debug = 1; my $img = Image::Magick->new(); $img->Read( "tif:" . ( -e $uri ? $uri : $def ) ); my ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mti +me, $ctime, $blksize, $blocks ) = stat($uri); my $scan_date; my $date_create = POSIX::strftime( '%d-%m-%Y %H:%M:%S', localtime $cti +me ); if ( $date_create =~ m/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}) +.*/ ) { $date_create = $3 . "." . $2 . "." . $1 . " " . $4 . ":" . $5 . ": +" . $6; } $scan_date = $date_create; $img->Annotate( y => 10, text => "Scanned: " . $scan_date, font => "ArialBkI", pointsize => 36, fill => 'white', gravity => 'north', undercolor => 'black', ); my $out = $img->ImageToBlob(); print "Content-type: image/tiff\n\n" . $out if ( $debug < 1 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Optimize runtime with Image::Magick;
by tangent (Parson) on Mar 07, 2019 at 00:32 UTC | |
|
Re: Optimize runtime with Image::Magick;
by vr (Curate) on Mar 07, 2019 at 10:40 UTC |