perlimagemagickperlmagick

Perl ImageMagick: how to disable printing of command output?


I have a Perl script:

#!/usr/bin/perl

use strict;

use Image::Magick;

my $temp_filename = 'temp.webp';

my $im = Image::Magick->new;
my $m = $im->Read($temp_filename);

When I run it from the command line, I get:

$ perl test.cgi
Decoded /tmp/magick-324583Dvjs7UCnJGp. Dimensions: 450 x 300. Now saving...
Saved file /tmp/magick-324589ZiUphKo482g
$

I expect (and want):

$ perl test.cgi
$

What gives?


Solution

  • Adding

    $im->SetAttribute(quiet=>1);
    

    fixed this issue for me.

    Final script:

    #!/usr/bin/perl
    
    use strict;
    
    use Image::Magick;
    
    my $temp_filename = 'temp.webp';
    
    my $im = Image::Magick->new;
    $im->SetAttribute(quiet=>1);
    my $m = $im->Read($temp_filename);