Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Cannot save all image formats after compiled to exe

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


in reply to Cannot save all image formats after compiled to exe

Assumed I missed any required file, I have just added files and still no effect, except the exe file becomes bigger:

pp test.pl -o test.exe -a "C:\Strawberry" -c -x

Did you test my code and packaged to exe using pp in your computer?
Succeed? Failed?
If failed, what you did to fix it?

I think the answer like that more helpful to me rather than provide hints about what is missing, etc.

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

    It may help if you tell us what formats don't work for you. It may also help if you tell us what versions of Perl and Imager you are using.

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

      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.

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

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

    No recent polls found