A
A
artem782017-09-14 19:09:03
Perl
artem78, 2017-09-14 19:09:03

How to speed up image resizing in perl?

There is a perl script that doubles the size of images in a folder. Now I'm using the ImageMagick module. Pictures sized 1024x768 are rotated for 8 seconds. With a large number of files, this is very long. Is there a way to speed this up?

my ($w, $h) = imgsize($filename);
my $img = new Image::Magick;
my $r = $img->Read($filename); # 0.5 сек
my ($w2, $h2) = ($w * 2, $h * 2);
$r = $img->Resize(width => $w2, height => $h2, filter => 'Lanczos'); # 5 сек
$img->Write($new_filename); # 2.5 сек

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya33, 2017-09-15
@Ilya33

Try experimenting with MAGICK_THREAD_LIMIT;
For example:
BEGIN { $ENV{MAGICK_THREAD_LIMIT} = 2; }

R
Roman Mirilaczvili, 2017-09-23
@2ord

Try image scaling with epeg library binding :
perl-users.jp/articles/advent-calendar/2010/english/22

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question