PerlMagick runs out of memory
Posted: 2007-07-25T22:08:00-07:00
Hi
We are using Perlmagick (Image::Magick) 6.0 for some time. We upgraded to 6.3.3 (CentOS, with 1GB of memory) and now the same program runs at of memory converting a 12Mb single page PDF file to a JPEG file.
While it use to die and report 'Endless loop' and 'Out of Memory', it might have been because we did not update Perlmagick but only Imagemagick. I since removed all 6.0 rpms, and reinstalled Imagemagick and perlmagick from source. Now it kswapd0 continually but does not compete or die.
Thank you for your help.
Here's the program:
We are using Perlmagick (Image::Magick) 6.0 for some time. We upgraded to 6.3.3 (CentOS, with 1GB of memory) and now the same program runs at of memory converting a 12Mb single page PDF file to a JPEG file.
While it use to die and report 'Endless loop' and 'Out of Memory', it might have been because we did not update Perlmagick but only Imagemagick. I since removed all 6.0 rpms, and reinstalled Imagemagick and perlmagick from source. Now it kswapd0 continually but does not compete or die.
Thank you for your help.
Here's the program:
Code: Select all
#!/usr/bin/perl -w
# $Id: myconvert.pl 26 2007-04-16 20:25:17Z dlink $
# This program behaves like a wrapper to ImageMagick's convert
# command line program. It allows us to: crop, rotate, and resize
# in that order, while the command line does not.
use strict;
use Image::Magick;
# inputs:
my ($crop, $rotation, $width, $input, $output) = @ARGV;
print "$crop, $rotation, $width, $input, $output\n" if $DEBUG;
die "myconvert.pl: incorrect number of arguments.\n" if $#ARGV != 4;
# Processing:
my $image = Image::Magick->new;
# Read
my $rc = $image->Read($input);
die $rc if "$rc";
# Crop
$rc = $image->Crop(geometry => $crop);
die $rc if $rc;
# Rotate
if ($rotation) {
$rc = $image->Rotate($rotation);
die $rc if $rc;
}
# Resize
$rc = $image->Resize($width);
die $rc if $rc;
# Write out
$rc = $image->Write($output);
die $rc if $rc;