社区
CGI
帖子详情
请问怎样用Perl获取远程图片的信息呢?
mylove0623
2008-08-05 11:53:09
请问怎样用Perl获取远程图片的信息呢?
...全文
152
11
打赏
收藏
请问怎样用Perl获取远程图片的信息呢?
请问怎样用Perl获取远程图片的信息呢?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
11 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
mylove0623
2008-08-05
打赏
举报
回复
没高手么?????
mylove0623
2008-08-05
打赏
举报
回复
宽度和高度
mylove0623
2008-08-05
打赏
举报
回复
忘记说了。我获取远程图片的有可能是php生成的图片。
mylove0623
2008-08-05
打赏
举报
回复
我明天测下盐水小鱼大哥的好使不。刚学perl。如果这个都不好使的话。我对perl就失去信心了。php都可以 getimagesize()
明天加100啊。放心啊。
mylove0623
2008-08-05
打赏
举报
回复
杀虫剂大哥。你说的
你试试这个模块Image::Size
my ($width, $height, $format) = ImageSize($filePath);
这个我试了。他只对存在本地服务器的图片好使。对于远程的。完全没用。
bigman_lfj
2008-08-05
打赏
举报
回复
use Image::Magick;
$image - Image::Magick->new;
($iwidth,$iheight,$isize,$iformat) = $image->Ping("..........your imgage file");
print "ping...".$iWidth;
----------------------------------------------
$image->Get("width","height")方法也是可以得到的。
wx红杉树
2008-08-05
打赏
举报
回复
你试试这个模块Image::Size
my ($width, $height, $format) = ImageSize($filePath);
wx红杉树
2008-08-05
打赏
举报
回复
要在 Perl 中获取图象文件的尺寸需要以二进制方式打开文件,然后读取尺寸数据并转换为整数;文件大小可以使用 Perl 标准功能完成。下面的代码只需调用 PictureSize 并使用文件路径参数就可以以数组的方式返回图象的宽度、高度和文件大小(注意: 这段程序只支持 JPG 和 GIF 文件):
---------------------------------------------------------------------
sub PictureSize {
my $gw = 0;
my $gh = 0;
my $gs = 0;
my $sl;
my $filepath = $_[0];
$gs = &FileSize($filepath);
if ($filepath eq '') {
return (0, 0, $gs);
}
open(FH, $filepath) || return (0, 0, $gs);
binmode FH;
read(FH, $buff, 3);
if ($buff eq 'GIF') { # Gif
read(FH, $buff, 3);
read(FH, $buff, 2);
$gw = &Str2Int($buff, 1);
read(FH, $buff, 2);
$gh = &Str2Int($buff, 1);
} elsif ($buff eq "\xff\xd8\xff") { # Jpg
read(FH, $buff, 1);
read(FH, $buff, 2);
$sl = &Str2Int($buff, 0);
read(FH, $buff, $sl);
read(FH, $buff, 2);
$sl = &Str2Int($buff, 0);
read(FH, $buff, $sl);
read(FH, $buff, 3);
read(FH, $buff, 2);
$gh = &Str2Int($buff, 0);
read(FH, $buff, 2);
$gw = &Str2Int($buff, 0);
}
close(FH);
return ($gw, $gh, $gs);
}
sub Str2Int {
my $str = $_[0];
my $mode = $_[1];
my $intnum;
if ($mode == 0) {
$intnum = ord(substr($str, 0, 1)) * 256 + ord(substr($str, 1, 1));
} else {
$intnum = ord(substr($str, 1, 1)) * 256 + ord(substr($str, 0, 1));
}
return $intnum;
}
sub FileSize {
return (-s $_[0]);
}
---------------------------------------------------------------------
调用方式为:
($picwidth, $picheight, $picsize) = &PictureSize($Pathname);
这里的 $Pathname 是文件路径。
---------------------------------------------------------------------
mylove0623
2008-08-05
打赏
举报
回复
高手来啊。我明天加到100分。
mylove0623
2008-08-05
打赏
举报
回复
我不想下载下来啊。
fnever
2008-08-05
打赏
举报
回复
下载下来再处理不就好了么,要看图片的具体格式的
update-weather.zip_WEB开发_
Perl
_
从新浪天气下载/切割页面 形成一个体积较小的html天气预报文件。包括
图片
。在ubuntu/apache环境下,wwwroot=/var/www
Sams.Publishing.Ubuntu.Unleashed.2008.Edition.pdf
Ubuntu Unleashed 2008 Edition Copyright © 2009 by Sams Publishing Introduction 1 Part I Installation and Configuration 1 Installing Ubuntu..........11 2 Post-Installation Configuration ........25 3 Working with Gnome...........51 4 Command Line Quickstart .........79 Part II Desktop Ubuntu 5 On the Internet...........113 6 Productivity Applications .........133 7 Multimedia Applications ..........153 8 Printing with Ubuntu .........185 9 Games............197 Part III System Administration 10 Managing Users...........209 11 Automating Tasks..........233 12 System-Monitoring Tools..........289 13 Backing Up............301 14 Networking............325 15 Remote Access with SSH and Telnet.......371 Part IV Ubuntu as a Server 16 File and Print...........381 17 Apache Web Server Management.......407 18 Remote File Serving with FTP.........439 19 Handling Electronic Mail..........471 20 Proxying and Reverse Proxying ........489 21 Administering Database Services ........499 22 LDAP............525 Part V Programming Linux 23 Using
Perl
............537 24 Working with Python .........561 25 Writing PHP Scripts...........579 26 C/C++ Programming Tools for Ubuntu......613 27 Mono.............625 Part VI Ubuntu Housekeeping 28 Securing Your Machines .........639 29 Performance Tuning..........651 30 Command Line Masterclass........663 31 Managing Software ...........689 32 Kernel and Module Management.......701 Part VII Appendixes A Ubuntu Under the Hood ..........727 B Installation Resources .........737 C Ubuntu and Linux Internet Resources .......759 Index ............???
Donkey Watcher-开源
一个开发软件的项目,该软件将允许用户通过万维网检索有关eDonkey2000客户端状态的
信息
和统计
信息
。 基于
Perl
的最大可移植性。
Web服务器的组建与.ppt
教你制作WEB服务器,里面有着详细的教程。有心学的朋友可以下载看看。
ffileman-开源
f-fileman 是一个用
Perl
编写的基于 Web 的文件和目录管理器。
CGI
2,204
社区成员
4,518
社区内容
发帖
与我相关
我的任务
CGI
Web 开发 CGI
复制链接
扫一扫
分享
社区描述
Web 开发 CGI
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章