Perl GD模块官网例子报错

#!/usr/bin/perl

 

use GD;

 

# create a new image

$im = new GD::Image(100,100);

 

# allocate some colors

$white = $im->colorAllocate(255,255,255);

$black = $im->colorAllocate(0,0,0);       

$red = $im->colorAllocate(255,0,0);      

$blue = $im->colorAllocate(0,0,255);

 

# make the background transparent and interlaced

$im->transparent($white);

$im->interlaced('true');

 

# Put a black frame around the picture

$im->rectangle(0,0,99,99,$black);

 

# Draw a blue oval

$im->arc(50,50,95,75,0,360,$blue);

 

# And fill it with red

$im->fill(50,50,$red);

 

# make sure we are writing to a binary stream

binmode STDOUT;

 

# Convert the image to PNG and print it on standard output

print $im->png;


报错:

attachments-2019-01-wWBJVSBZ5c31ada93115f.jpg

请先 登录 后评论

最佳答案 2019-01-07 16:37

PNG文件输出是二进制文件,当然是乱码了,你再看看GD包如何输出PNG图片;

绘图不建议用perl的GD包,太麻烦了;建议学习R的绘图  或者perl的SVG绘图;

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,3469 浏览
  • 不一样 提出于 2019-01-06 15:26

相似问题