Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

add gdimage output #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qrconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false

define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
define('QR_GDIMAGE_MAXIMUM_SIZE', 1024);
15 changes: 15 additions & 0 deletions qrencode.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size
return $enc->encodePNG($text, $outfile, $saveandprint=false);
}

//----------------------------------------------------------------------
public static function gdimage($text, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
{
$enc = QRencode::factory($level, $size, $margin);
return $enc->encodeGDIMAGE($text);
}

//----------------------------------------------------------------------
public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4)
{
Expand Down Expand Up @@ -566,4 +573,12 @@ public function encodeSVG($intext, $outfile = false,$saveandprint=false)

}
}

//----------------------------------------------------------------------
public function encodeGDIMAGE($intext)
{
$tab = $this->encode($intext);
$maxSize = (int)(QR_GDIMAGE_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
return QRimage::gdimage($tab, min(max(1, $this->size), $maxSize), $this->margin);
}
}
6 changes: 6 additions & 0 deletions qrimage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public static function png($frame, $filename = false, $pixelPerPoint = 4, $outer
ImageDestroy($image);
}

//----------------------------------------------------------------------
public static function gdimage($frame, $pixelPerPoint = 4, $outerFrame = 4)
{
return self::image($frame, $pixelPerPoint, $outerFrame);
}

//----------------------------------------------------------------------
public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85)
{
Expand Down