Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Cannot save all image formats after compiled to exe

by CKEQvc (Novice)
on Dec 29, 2020 at 02:51 UTC ( [id://11125909]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Cannot save all image formats after compiled to exe
in thread Cannot save all image formats after compiled to exe

Hope these information enough.

Perl v5.32.0
Imager v1.012
Imager::QRCode v0.035

Saved image formats: BMP, RAW, TGA, PNM.
Other formats are not saved.

  • Comment on Re^3: Cannot save all image formats after compiled to exe

Replies are listed 'Best First'.
Re^4: Cannot save all image formats after compiled to exe
by GrandFather (Saint) on Dec 29, 2020 at 05:36 UTC

    I installed Imager::QRCode and PAR::Packer using cpan then used pp test.pl -o test.exe -c -x to generate a 7.8MB test.exe. I got the same results that you did. I then reworked your code to give better diagnostics and to be a little more modern (using lexical file handles):

    use strict; use warnings; use diagnostics; use Imager; use Imager::QRCode; use Imager::File::JPEG; my $qrcode = Imager::QRCode->new ( size => 2, margin => 2, version => 1, level => 'M', casesensitive => 1, lightcolor => Imager::Color->new(255, 255, 255), darkcolor => Imager::Color->new(0, 0, 0), ); my $img = $qrcode->plot('PDJ Test 1'); my @type = ('jpeg', 'png', 'gif', 'tiff', 'bmp', 'pnm', 'raw', 'sgi', +'tga'); for (@type) { my $fileName = "image.$_"; open my $image, '>', $fileName or die $!; binmode $image or die $!; my $imageOut = $img->write(fh => $image, type => $_) or die "Creat +ing $fileName: $!"; print $image $imageOut; }

    When packed and the executable is run I get errors like:

    Uncaught exception from user code: Creating image.png: No such file or directory at script/delme. +pl line 28.

    As you can see from the sample code above explicitly including the appropriate image file modules fixes the problem (.jpg was a problematic format on my system). You could of course use -M Imager::File::JPEG ... on the pp command line to achieve the same result.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-19 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found