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!