Глядя на библиотеку PHP QR Code, есть только один файл (я думаю), который обращается к библиотеке GD: qrimage.php .Поэтому измените этот файл на вывод через imagick и используйте оставшуюся часть PHP QR Code.
Ниже приведен возможный выходной файл imagick, который я написал для замены qrimage.php .Однако я не могу проверить этот код, так как я нахожусь в Windows и не могу установить imagick.
Может кто-нибудь отладить его и отредактировать этот пост с любыми исправлениями?
<?php
/*
* PHP QR Code encoder
*
* Image output of code using GD2
*
* PHP QR Code is distributed under LGPL 3
* Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define('QR_IMAGE', true);
class QRimage {
//----------------------------------------------------------------------
public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE)
{
$image = self::image($frame, $pixelPerPoint, $outerFrame, "png", 85, $filename, $saveandprint);
}
//----------------------------------------------------------------------
public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85)
{
$image = self::image($frame, $pixelPerPoint, $outerFrame, "jpeg", $q, $filename, $saveandprint);
}
//----------------------------------------------------------------------
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4,
$format = "png", $quality = 85, $filename = FALSE, $saveandprint = FALSE)
{
$imgH = count($frame);
$imgW = strlen($frame[0]);
$col[0] = new ImagickPixel("white");
$col[1] = new ImagickPixel("black");
$image = new Imagick();
$image->newImage($imgW, $imgH, $col[0]);
$image->setCompressionQuality($quality);
$image->setImageFormat($format);
$draw = new ImagickDraw();
$draw->setFillColor($col[1]);
for($y=0; $y<$imgH; $y++) {
for($x=0; $x<$imgW; $x++) {
if ($frame[$y][$x] == '1') {
$draw->point($x,$y);
}
}
}
$image->drawImage($draw);
$image->borderImage($col[0],$outerFrame,$outerFrame);
$image->scaleImage( $imgW * $pixelPerPoint, 0 );
if ($filename === FALSE) {
Header("Content-type: image/jpeg");
echo $image;
} else {
if($saveandprint===TRUE){
$image->writeImages($filename, true);
Header("Content-type: image/" . $format);
echo $image;
} else {
echo $image;
}
}
}
}
Существует объединенный файл с именем phpqrcode.php который содержит весь qrimage.php , поэтому вам придется либо заново объединить этот файл, либо заменить соответствующий раздел.
Если вы используете другое имя файла для вышеуказанного кода, вам придется изменить ссылку в файле qrlib.php и merge.php .