How can I use IO::Scalar with Image::Magick::Read()?

后端 未结 2 1508
一生所求
一生所求 2021-01-14 05:19

I have an image I have manipulated with GD::Image and I want to do further manipulations with Image::Magick. I\'d like to avoid writing the image out to disk just so Image:

2条回答
  •  暖寄归人
    2021-01-14 06:06

    I think you are looking for BlobToImage:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use File::Slurp;
    use Image::Magick;
    
    my $image_bin = read_file 'test.jpg', binmode => ':raw';
    
    my $magick = Image::Magick->new;
    
    $magick->BlobToImage( $image_bin );
    
    $magick->Resize( geometry => '64x64' );
    
    $magick->Write( 'test-out.jpg' );
    
    __END__
    

提交回复
热议问题