Uni9k
V2EX  ›  HTML

求助一下关于 imagepng 无法显示

  •  
  •   Uni9k · Apr 15, 2016 · 3985 views
    This topic created in 3707 days ago, the information mentioned may be changed or developed.

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

    4 replies    2016-04-15 22:24:29 +08:00
    Uni9k
        1
    Uni9k  
    OP
       Apr 15, 2016
    ##<?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  
       Apr 15, 2016
    不是很懂你 imagepng('qrcode.png'); 是怎么想的。
    不考虑并发,按你这个思路,这个代码应该是: header("Content-Type: image/png"); readfile('qrcode.png');
    但是你要考虑并发的话,你这个思路不太对。
    oott123
        3
    oott123  
       Apr 15, 2016
    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
       Apr 15, 2016
    @oott123 我之前只是看的网上的一些资料 他们给出的 imagepng 输出 png ,多谢了。万分感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1025 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:10 · PVG 03:10 · LAX 12:10 · JFK 15:10
    ♥ Do have faith in what you're doing.