求助一下关于 imagepng 无法显示

2016-04-15 18:41:53 +08:00
 Uni9k

浏览器中无法显示,但是已经生成了图片文件。求助下~ #######################

3271 次点击
所在节点    HTML
4 条回复
Uni9k
2016-04-15 18:42:20 +08:00
##<?php
include 'phpqrcode.php';
$value = $_GET['url'];//二维码内容
$errorCorrectionLevel = 'L';//容错级别
$matrixPointSize = 6;//生成图片大小
//生成二维码图片
QRcode::png($value, 'qrcode.png', $errorCorrectionLevel, $matrixPointSize, 2);
$QR = 'qrcode.png';//已经生成的原始二维码图

//输出图片
Header("Content-type: image/png");
imagepng($QR);
imagedestroy($QR);
?>##
oott123
2016-04-15 19:32:06 +08:00
不是很懂你 imagepng('qrcode.png'); 是怎么想的。
不考虑并发,按你这个思路,这个代码应该是: header("Content-Type: image/png"); readfile('qrcode.png');
但是你要考虑并发的话,你这个思路不太对。
oott123
2016-04-15 19:33:52 +08:00
Usage

To install simply include:

qrlib.php for full version (also you have to provide all library files form package plus cache dir)
OR phpqrcode.php for merged version (only one file, but slower and less accurate code because disabled cache and quicker masking configured)

Then use it as follows:

QRcode::png('code data text', 'filename.png'); // creates file
QRcode::png('some othertext 1234'); // creates code image and outputs it directly into browser

---
via http://phpqrcode.sourceforge.net/

注意我复制的最后一行。
Uni9k
2016-04-15 22:24:29 +08:00
@oott123 我之前只是看的网上的一些资料 他们给出的 imagepng 输出 png ,多谢了。万分感谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/271413

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX