V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Dive into HTML5
http://diveintohtml5.org/
Uni9k
V2EX  ›  HTML

求助一下关于 imagepng 无法显示

  •  
  •   Uni9k · 2016-04-15 18:41:53 +08:00 · 3260 次点击
    这是一个创建于 2926 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    4 条回复    2016-04-15 22:24:29 +08:00
    Uni9k
        1
    Uni9k  
    OP
       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
        2
    oott123  
       2016-04-15 19:32:06 +08:00
    不是很懂你 imagepng('qrcode.png'); 是怎么想的。
    不考虑并发,按你这个思路,这个代码应该是: header("Content-Type: image/png"); readfile('qrcode.png');
    但是你要考虑并发的话,你这个思路不太对。
    oott123
        3
    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
        4
    Uni9k  
    OP
       2016-04-15 22:24:29 +08:00
    @oott123 我之前只是看的网上的一些资料 他们给出的 imagepng 输出 png ,多谢了。万分感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2962 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:04 · PVG 11:04 · LAX 20:04 · JFK 23:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.