简体   繁体   中英

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM