如何使用Perl显示图像 [英] How to display an image with Perl

查看:136
本文介绍了如何使用Perl显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个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?

谢谢。

推荐答案

首先,您可以使用 LWP :: Simple 获取图像并将其保存到磁盘。

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

之后, Windows 上最简单的事情就是

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.

OS X 上,您可以

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

freedesktop.org 符合标准的系统你可以做到

On freedesktop.org standard compliant systems you can do

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

这些涉及在命令行应用程序和OS指定的应用程序之间切换以查看图像。如果您希望它更加无缝,您可以使用 Perl GUI库并创建一个下载的窗口图片

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

这篇关于如何使用Perl显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆