Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display an image with Perl

Tags:

image

perl

I want to write a perl script to auto login a website and do some interesting things. The problem is that the website which I want to log into has a captcha image. I don't have the ability to anticaptcha it, so I need to read the image then display the image to the user to let the user reads the characters on the image, then type the character in the command line back to the program. I want to know, what is the easiest way to display an image to the user?

Thanks.

like image 990
Just a learner Avatar asked Dec 28 '22 07:12

Just a learner


1 Answers

Firstly you can use LWP::Simple to fetch the image and save it to disk.

Afterwards , the simplest thing on Windows is to do

  system("C:\\imagepath\\foo.jpg");

which will show the image in the default application that is used to display it.

On OS X you can do

 system("open ~/imagepath/foo.jpg");

On freedesktop.org standard compliant systems you can do

 system("xdg-open ~/imagepath/foo.jpg");

These involve switching between a command line app and the OS designated application to view the image. If you want it more seamless you can use a Perl GUI library and create a window with downloaded image

like image 155
parapura rajkumar Avatar answered Jan 30 '23 10:01

parapura rajkumar