Dear wise Monks,

I wrote a script that analyses image files using the GD module. Initially the script reads an image file using the Imager module in order to convert it to png format that is required by GD.

The script works fine but when I pack the script into a single executable file (PAR::Packer command: pp -o convert.exe convert.pl -c) the Imager module seems to have problems to open the file. Can anyone help me to fix it?

use Tk; use Imager; $mw=MainWindow->new(); $filetypes= [ ['Image Files',['.bmp','.gif','.jpg','.jpeg','.png','.tif']], ['All Files','*'], ]; $mw->Button ( -text=>"browse", -command=>sub { # get file to open $filename=$mw->getOpenFile ( -filetypes=>$filetypes, ); # check if file exists if(-e $filename) { # read file using the Imager module $image_any_format=Imager->new; unless($image_any_format->read(file=>$filename)) { $mw->messageBox(-message=>"Error! Unable to read file +'$filename'\n$!",-type=>'ok',-icon=>'error'); } # convert the file to .png format unless($image_any_format->write(file=>"image.png",type =>' +png')) { $mw->messageBox(-message=>"Error! Unable to write file +.\n$!",-type=>'ok',-icon=>'error'); } } else { $mw->messageBox(-message=>"Error! '$filename' does not exi +st\n$!",-type=>'ok',-icon=>'error'); } } )->pack(); $mw->Button ( -text=>"exit", -command=>sub{exit;} )->pack(); MainLoop;

If this may be relevant: I'm on a Windows 7 (64bit) system with Perl 5.16.2

Thanks for your help!

In reply to Cannot read file with Imager when script is packed into an executable file with PAR::Packer by Microcebus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.