mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-29 19:48:17 +00:00
✨ added QRGdImageAVIF
This commit is contained in:
@@ -83,6 +83,7 @@ abstract class QRGdImage extends QROutputAbstract{
|
||||
}
|
||||
|
||||
$modes = [
|
||||
QRGdImageAVIF::class => 'AVIF Support',
|
||||
QRGdImageBMP::class => 'BMP Support',
|
||||
QRGdImageGIF::class => 'GIF Create Support',
|
||||
QRGdImageJPEG::class => 'JPEG Support',
|
||||
@@ -90,7 +91,7 @@ abstract class QRGdImage extends QROutputAbstract{
|
||||
QRGdImageWEBP::class => 'WebP Support',
|
||||
];
|
||||
|
||||
// likely using custom output
|
||||
// likely using custom output/manual invocation
|
||||
if(!isset($modes[$this->options->outputInterface])){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Class QRGdImageAVIF
|
||||
*
|
||||
* @created 26.11.2023
|
||||
* @author smiley <smiley@chillerlan.net>
|
||||
* @copyright 2023 smiley
|
||||
* @license MIT
|
||||
*
|
||||
* @noinspection PhpComposerExtensionStubsInspection
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCode\Output;
|
||||
|
||||
use function imageavif, max, min;
|
||||
|
||||
/**
|
||||
* GDImage avif output
|
||||
*
|
||||
* @see \imageavif()
|
||||
*/
|
||||
class QRGdImageAVIF extends QRGdImage{
|
||||
|
||||
final public const MIME_TYPE = 'image/avif';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function renderImage():void{
|
||||
imageavif($this->image, null, max(-1, min(100, $this->options->quality)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,18 +24,19 @@ interface QROutputInterface{
|
||||
* @see https://github.com/chillerlan/php-qrcode/issues/223
|
||||
*/
|
||||
public const MODES = [
|
||||
QRMarkupSVG::class,
|
||||
QRMarkupHTML::class,
|
||||
QREps::class,
|
||||
QRFpdf::class,
|
||||
QRGdImageAVIF::class,
|
||||
QRGdImageBMP::class,
|
||||
QRGdImageGIF::class,
|
||||
QRGdImageJPEG::class,
|
||||
QRGdImagePNG::class,
|
||||
QRGdImageWEBP::class,
|
||||
QRImagick::class,
|
||||
QRMarkupHTML::class,
|
||||
QRMarkupSVG::class,
|
||||
QRStringJSON::class,
|
||||
QRStringText::class,
|
||||
QRImagick::class,
|
||||
QRFpdf::class,
|
||||
QREps::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Class QRGdImageAVIFTest
|
||||
*
|
||||
* @created 27.11.2023
|
||||
* @author smiley <smiley@chillerlan.net>
|
||||
* @copyright 2023 smiley
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Output;
|
||||
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCodeTest\Output\QRGdImageTestAbstract;
|
||||
use chillerlan\QRCode\Output\{QRGdImageAVIF, QROutputInterface};
|
||||
use chillerlan\Settings\SettingsContainerInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class QRGdImageAVIFTest extends QRGdImageTestAbstract{
|
||||
|
||||
protected function getOutputInterface(
|
||||
SettingsContainerInterface|QROptions $options,
|
||||
QRMatrix $matrix
|
||||
):QROutputInterface{
|
||||
return new QRGdImageAVIF($options, $matrix);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,9 +40,9 @@ abstract class QROutputTestAbstract extends TestCase{
|
||||
mkdir($this::buildDir, 0777, true);
|
||||
}
|
||||
|
||||
$this->options = new QROptions;
|
||||
$this->matrix = (new QRCode($this->options))->addByteSegment('testdata')->getQRMatrix();
|
||||
$this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
|
||||
$this->options = new QROptions;
|
||||
$this->matrix = (new QRCode($this->options))->addByteSegment('testdata')->getQRMatrix();
|
||||
$this->outputInterface = $this->getOutputInterface($this->options, $this->matrix);
|
||||
}
|
||||
|
||||
abstract protected function getOutputInterface(
|
||||
|
||||
Reference in New Issue
Block a user