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 exist\n$!",-type=>'ok',-icon=>'error'); } } )->pack(); $mw->Button ( -text=>"exit", -command=>sub{exit;} )->pack(); MainLoop;