免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4242 | 回复: 12

有没有Perl生成二维码图片的模块? [复制链接]

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-09 06:20:00
发表于 2013-04-22 16:15 |显示全部楼层
现在需要在程序中对特定信息生成二维码图,在CPAN上没找到,也可能有但是我没找到

论坛徽章:
0
发表于 2013-04-22 17:50 |显示全部楼层
搜索了下qrcode 一堆啊 :wink:

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-09 06:20:00
发表于 2013-04-22 18:53 |显示全部楼层
所以当时觉得奇怪了,我是查的“two dimension code”,没查“qrcode ”

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-09 06:20:00
发表于 2013-04-23 10:07 |显示全部楼层
本帖最后由 unix666 于 2013-04-23 10:08 编辑

安装了
  1. Imager::QRCode
复制代码
用自带的例子程序:
  1. use Imager::QRCode;

  2. my $qrcode = Imager::QRCode->new(
  3. size  => 2,
  4. margin=> 2,
  5. version   => 1,
  6. level => 'M',
  7. casesensitive => 1,
  8. lightcolor=> Imager::Color->new(255, 255, 255),
  9. darkcolor => Imager::Color->new(0, 0, 0),
  10. );
  11. my $img = $qrcode->plot("blah blah");
  12. $img->write(file => "qrcode.gif");
复制代码
运行后没生成qrcode.gif,当前目录是可写的,请教怎么回事

论坛徽章:
0
发表于 2013-04-23 10:44 |显示全部楼层
打开strict和warning。然后看看error信息~

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-09 06:20:00
发表于 2013-04-23 11:10 |显示全部楼层
试了,打开strict和warning,没有任何error信息,求解

论坛徽章:
0
发表于 2013-04-23 15:03 |显示全部楼层
回复 4# unix666

刚试了试没问题,改成下面的看看
  1. $img->write(file => "qrcode.gif") or die  $img->errstr;
复制代码
可能是没有写权限     

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-09 06:20:00
发表于 2013-04-23 17:14 |显示全部楼层
感谢!写权限倒是有的,加上了or die  $img->errstr; 看到了错误提示:

format 'gif' not supported - formats bmp, ico, pnm, raw, sgi, tga available for writing - Can't locate Imager/File/GIF.pm at qrcode.pl line 17.

改为:
$img->write(file => "qrcode.bmp") or die  $img->errstr;

生成了bmp格式的二维码图。

看样装个Imager::File::GIF应该可以出来gif图了。

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-09 06:20:00
发表于 2013-04-23 18:20 |显示全部楼层
  1. 又有问题了,生成bmp格式的二维码图没问题,可我需要的是gif格式的。

  2. 安装Imager::File::GIF
  3. cpan> install Imager::File::GIF

  4. 错误提示:
  5. GIF: building independently
  6. GIF: main: includes not found - libraries not found
  7. GIF: Checking if the compiler can find them on its own
  8. GIF: Test code failed: Can't link/include 'gif_lib.h', 'stdio.h', 'errno.h', 'string.h', 'gif'
  9. OS unsupported: GIF libraries or headers not found
  10. Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
  11.   TONYC/Imager-File-GIF-0.87.tar.gz
  12.   /usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK

  13. 继续求解
复制代码

论坛徽章:
0
发表于 2013-04-23 18:48 |显示全部楼层
回复 9# unix666

安装对应发行版本下的 giflib
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP