Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by GrandFather (Saint)
on Dec 29, 2020 at 05:36 UTC ( [id://11125916]=note: print w/replies, xml ) Need Help??


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

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://11125916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-25 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found