I am using Imager on a Windows test computer. It is processing about 60 files. I realise image processing is CPU intensive ... but the browser times out before the process has run - about 60 seconds. For PERL, that seems incredibly slow, so I must be doing something wrong
The files are approx 3508px x 2480px -jpg. I am reducing down to 750 wide, and another 150px tall. The third is being rotated 90 degrees anti-clockwise. (I found out it cannot handle type=>jpg,so changed that to "type='jpeg'" wcev though the extension is '.jpg')
I placed the new image outside of the loop thinking that once created, it would use the same variable. Here then is the code:
$dir=$baseURL.$type."/"; # Reads the photos in master folder. Calle +d 3 times via external loop opendir my $dh, $dir or die "Could not open '$dir' for reading '$!'\n" +; @pics = grep(/\.jpg$/,readdir $dh); closedir $dh; shift @pics; ## Removes the dot files shift @pics; $tot=@pics; $img=Imager->new(); # create empty image for (my $p=0; $p<@pics; $p++){ $img->read(file=>$baseURL.$type.'/'.$pics[$p],type=>'jpeg') or di +e $img->errstr(); my $med = $img->copy(); my $thumb = $img->copy(); $med = $img->scale(xpixels=>750);# sets width to 750px $med->write(file=>$baseURL.$type.'/medium/'.$pics[$p]) or die $ima +ge->errstr; # Write out image $thumb = $img->scale(ypixels=>150);# sets the height to 150px $thumb->write(file=>$baseURL.$type.'/thumbs/'.$pics[$p]) or die $i +mage->errstr; # Write out image my $rot90 = $img->rotate(degrees=>-90); $rot90->write(file=>$baseURL.$type.'/upright/'.$pics[$p]) or die $ +image->errstr; # Write out image my @pic=split(/\./,$pics[$p]); # splits filename at dot [filename] +[jpg] $newDat.=$pic[0].'|'; # Used in a latter part of program }
Just tries a little experiment. Two files of 10630 x 2480 took 10 seconds to process. Add 16 images of 5315px x 2480px, and browser times out after 70 secs before files are processed. (If I cut out the image processing, it can read the files, split filenames and create textfiles in about 0.5sec)
I don't really want to resort to ImageMagic as I cannot get the perlMagic interface to install on Windows offline test machine. And GD produces some poor results, messing with the colours.
Is it perhaps running out of memory, and I somehow need to clear it out before processing each image. The docs don;t eplain that as it seems to mainly work on one image at a time
Oh, and as I'm writing this Dec 23rd, "MERRY CHRISTMAS, ONE AND ALL !!"
In reply to Imager: Gateway Timeout by cristofayre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |