mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-09-15 12:16:25 +00:00
:octocat: support compression quality in QRImagick
This commit is contained in:
@@ -18,11 +18,13 @@ $options = new QROptions;
|
||||
|
||||
$options->version = 7;
|
||||
$options->outputType = QROutputInterface::IMAGICK;
|
||||
$options->imagickFormat = 'webp';
|
||||
$options->quality = 90;
|
||||
$options->scale = 20;
|
||||
$options->outputBase64 = false;
|
||||
$options->bgColor = '#ccccaa';
|
||||
$options->imageTransparent = true;
|
||||
#$options->transparencyColor = '#ECF9BE';
|
||||
$options->transparencyColor = '#ccccaa';
|
||||
$options->drawLightModules = true;
|
||||
$options->drawCircularModules = true;
|
||||
$options->circleRadius = 0.4;
|
||||
@@ -63,7 +65,7 @@ $options->moduleValues = [
|
||||
$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
|
||||
|
||||
|
||||
header('Content-type: image/png');
|
||||
header('Content-type: image/webp');
|
||||
|
||||
echo $out;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace chillerlan\QRCode\Output;
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\Settings\SettingsContainerInterface;
|
||||
use finfo, Imagick, ImagickDraw, ImagickPixel;
|
||||
use function extension_loaded, in_array, is_string, preg_match, strlen;
|
||||
use function extension_loaded, in_array, is_string, max, min, preg_match, strlen;
|
||||
use const FILEINFO_MIME_TYPE;
|
||||
|
||||
/**
|
||||
@@ -121,6 +121,10 @@ class QRImagick extends QROutputAbstract{
|
||||
|
||||
$this->imagick->newImage($this->length, $this->length, $this->background, $this->options->imagickFormat);
|
||||
|
||||
if($this->options->quality > -1){
|
||||
$this->imagick->setImageCompressionQuality(max(0, min(100, $this->options->quality)));
|
||||
}
|
||||
|
||||
$this->drawImage();
|
||||
// set transparency color after all operations
|
||||
$this->setTransparencyColor();
|
||||
|
||||
Reference in New Issue
Block a user