Microcebus has asked for the wisdom of the Perl Monks concerning the following question:

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!
  • Comment on Cannot read file with Imager when script is packed into an executable file with PAR::Packer
  • Download Code

Replies are listed 'Best First'.
Re: Cannot read file with Imager when script is packed into an executable file with PAR::Packer ( pp -x )
by Anonymous Monk on Jul 29, 2013 at 12:19 UTC
      Of course. That's it. Thanks!
Re: Cannot read file with Imager when script is packed into an executable file with PAR::Packer
by Microcebus (Beadle) on Jul 29, 2013 at 12:18 UTC
    I have no idea if this is informative... when I print the name of the file including the path I get something like //Computername/path/image rather than C:/path/image