diff --git a/docs/API-QROptions.md b/docs/API-QROptions.md index 4a530389c..5efa1494c 100644 --- a/docs/API-QROptions.md +++ b/docs/API-QROptions.md @@ -39,7 +39,7 @@ Inherited from [`SettingsContainerAbstract`](https://github.com/chillerlan/php-s | `$outputInterface` | `string\|null` | `null` | * | The FQCN of the custom `QROutputInterface` if `QROptions::$outputType` is set to `QROutputInterface::CUSTOM` | | `$returnResource` | `bool` | `false` | * | Return the image resource instead of a render if applicable. | | `$cachefile` | `string\|null` | `null` | * | Optional cache file path | -| `$imageBase64` | `bool` | `true` | * | Toggle base64 or raw image data (if applicable) | +| `$outputBase64` | `bool` | `true` | * | Toggle base64 data URI or raw data output (if applicable) | | `$eol` | `string` | `PHP_EOL` | * | Newline string (HTML, SVG, TEXT) | | `$bgColor` | `mixed` | `null` | a valid FPDF, GD or Imagick color value | Sets the image background color (if applicable). QRImagick: defaults to "white", QRGdImage: defaults to [255, 255, 255], QRFpdf: defaults to blank internally (white page) | | `$drawLightModules` | `bool` | `true` | * | Whether to draw the light (false) modules | diff --git a/docs/Usage-Advanced-usage.md b/docs/Usage-Advanced-usage.md index ee5bbc088..d4c18d083 100644 --- a/docs/Usage-Advanced-usage.md +++ b/docs/Usage-Advanced-usage.md @@ -126,8 +126,8 @@ $qrcode->setOptions($options); Save the QR Code output to `/path/to/qrcode.svg`: ```php -$options->imageBase64 = false; -$options->cachefile = '/path/to/qrcode.svg'; +$options->outputBase64 = false; +$options->cachefile = '/path/to/qrcode.svg'; $qrcode->render($data); ``` diff --git a/docs/Usage-Quickstart.md b/docs/Usage-Quickstart.md index 938aba00d..fbab72db0 100644 --- a/docs/Usage-Quickstart.md +++ b/docs/Usage-Quickstart.md @@ -27,8 +27,8 @@ Configuration using `QROptions`: ```php $options = new QROptions; -$options->version = 7; -$options->imageBase64 = false; // output raw image instead of base64 data URI +$options->version = 7; +$options->outputBase64 = false; // output raw image instead of base64 data URI header('Content-type: image/svg+xml'); // the image type is SVG by default diff --git a/examples/authenticator.php b/examples/authenticator.php index ec83dda09..18db37429 100644 --- a/examples/authenticator.php +++ b/examples/authenticator.php @@ -35,7 +35,7 @@ $options->algorithm = AuthenticatorInterface::ALGO_SHA512; */ $options->version = 7; $options->addQuietzone = false; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->svgAddXmlHeader = false; $options->cssClass = 'my-qrcode'; $options->drawLightModules = false; diff --git a/examples/fpdf.php b/examples/fpdf.php index fa231718d..465b284da 100644 --- a/examples/fpdf.php +++ b/examples/fpdf.php @@ -21,7 +21,7 @@ $options->scale = 5; $options->fpdfMeasureUnit = 'mm'; $options->bgColor = [222, 222, 222]; $options->drawLightModules = false; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->moduleValues = [ // finder QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true) diff --git a/examples/image.php b/examples/image.php index 165386642..8fa29778c 100644 --- a/examples/image.php +++ b/examples/image.php @@ -19,7 +19,7 @@ $options = new QROptions; $options->version = 7; $options->outputType = QROutputInterface::GDIMAGE_PNG; $options->scale = 20; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->bgColor = [200, 150, 200]; $options->imageTransparent = true; #$options->transparencyColor = [233, 233, 233]; diff --git a/examples/imageWithLogo.php b/examples/imageWithLogo.php index 522fa4b53..1f7e925f5 100644 --- a/examples/imageWithLogo.php +++ b/examples/imageWithLogo.php @@ -63,7 +63,7 @@ class QRImageWithLogo extends QRGdImage{ $this->saveToFile($imageData, $file); - if($this->options->imageBase64){ + if($this->options->outputBase64){ $imageData = $this->toBase64DataURI($imageData, 'image/'.$this->options->outputType); } @@ -80,7 +80,7 @@ class QRImageWithLogo extends QRGdImage{ $options = new QROptions; $options->version = 5; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->scale = 6; $options->imageTransparent = false; $options->drawCircularModules = true; diff --git a/examples/imageWithText.php b/examples/imageWithText.php index 8de9dc880..1c74fd255 100644 --- a/examples/imageWithText.php +++ b/examples/imageWithText.php @@ -42,7 +42,7 @@ class QRImageWithText extends QRGdImage{ $this->saveToFile($imageData, $file); - if($this->options->imageBase64){ + if($this->options->outputBase64){ $imageData = $this->toBase64DataURI($imageData, 'image/'.$this->options->outputType); } @@ -96,10 +96,10 @@ class QRImageWithText extends QRGdImage{ $options = new QROptions; -$options->version = 7; -$options->outputType = QROutputInterface::GDIMAGE_PNG; -$options->scale = 3; -$options->imageBase64 = false; +$options->version = 7; +$options->outputType = QROutputInterface::GDIMAGE_PNG; +$options->scale = 3; +$options->outputBase64 = false; $qrcode = new QRCode($options); diff --git a/examples/imagick.php b/examples/imagick.php index 7235d72aa..2b2210c84 100644 --- a/examples/imagick.php +++ b/examples/imagick.php @@ -19,7 +19,7 @@ $options = new QROptions; $options->version = 7; $options->outputType = QROutputInterface::IMAGICK; $options->scale = 20; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->bgColor = '#ccccaa'; $options->imageTransparent = true; #$options->transparencyColor = '#ECF9BE'; diff --git a/examples/imagickWithLogo.php b/examples/imagickWithLogo.php index 358b6b502..0fd7f1986 100644 --- a/examples/imagickWithLogo.php +++ b/examples/imagickWithLogo.php @@ -54,7 +54,7 @@ class QRImagickWithLogo extends QRImagick{ $this->imagick->destroy(); $this->saveToFile($imageData, $file); - if($this->options->imageBase64){ + if($this->options->outputBase64){ $imageData = $this->toBase64DataURI($imageData, (new finfo(FILEINFO_MIME_TYPE))->buffer($imageData)); } @@ -101,7 +101,7 @@ $options->version = 5; $options->outputType = QROutputInterface::CUSTOM; $options->outputInterface = QRImagickWithLogo::class; // use the custom output class $options->eccLevel = EccLevel::H; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->addLogoSpace = true; $options->logoSpaceWidth = 15; $options->logoSpaceHeight = 15; diff --git a/examples/multimode.php b/examples/multimode.php index d8a4e5bb6..a7963d011 100644 --- a/examples/multimode.php +++ b/examples/multimode.php @@ -19,7 +19,7 @@ mb_internal_encoding('UTF-8'); // please excuse the IDE yelling https://youtrack.jetbrains.com/issue/WI-66549 $options = new QROptions; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->connectPaths = true; $qrcode = (new QRCode($options)) diff --git a/examples/qrcode-interactive.php b/examples/qrcode-interactive.php index df477bfbb..2127e1a5f 100644 --- a/examples/qrcode-interactive.php +++ b/examples/qrcode-interactive.php @@ -67,7 +67,7 @@ try{ 'moduleValues' => $moduleValues, 'outputType' => $_POST['output_type'], 'scale' => (int)$_POST['scale'], - 'imageBase64' => true, + 'outputBase64' => true, 'imageTransparent' => false, ]); diff --git a/examples/reflectance.php b/examples/reflectance.php index 5887deb45..80c8dbba4 100644 --- a/examples/reflectance.php +++ b/examples/reflectance.php @@ -19,7 +19,7 @@ require_once __DIR__.'/../vendor/autoload.php'; $options = new QROptions; $options->outputType = QROutputInterface::MARKUP_SVG; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->svgAddXmlHeader = false; $options->connectPaths = true; $options->drawCircularModules = false; diff --git a/examples/svg.php b/examples/svg.php index 3ad4ef554..3ae578fe1 100644 --- a/examples/svg.php +++ b/examples/svg.php @@ -20,7 +20,7 @@ $options = new QROptions; $options->version = 7; $options->outputType = QROutputInterface::MARKUP_SVG; -$options->imageBase64 = false; +$options->outputBase64 = false; // if set to false, the light modules won't be rendered $options->drawLightModules = true; // empty the default value to remove the fill* and opacity* attributes from the elements diff --git a/examples/svgMeltedModules.php b/examples/svgMeltedModules.php index 94952dc57..4d92cdacd 100644 --- a/examples/svgMeltedModules.php +++ b/examples/svgMeltedModules.php @@ -256,7 +256,7 @@ $options->meltRadius = 0.4; $options->version = 7; $options->outputType = QROutputInterface::CUSTOM; $options->outputInterface = MeltedSVGQRCodeOutput::class; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->addQuietzone = true; $options->eccLevel = EccLevel::H; $options->addLogoSpace = true; diff --git a/examples/svgRandomColoredDots.php b/examples/svgRandomColoredDots.php index 9a3e6e063..b3962e558 100644 --- a/examples/svgRandomColoredDots.php +++ b/examples/svgRandomColoredDots.php @@ -135,7 +135,7 @@ $options->outputInterface = RandomDotsSVGOutput::class; $options->version = 5; $options->eccLevel = EccLevel::H; $options->addQuietzone = true; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->drawLightModules = false; $options->connectPaths = true; $options->excludeFromConnect = [ diff --git a/examples/svgRoundQuietzone.php b/examples/svgRoundQuietzone.php index bd3773a58..307af8e51 100644 --- a/examples/svgRoundQuietzone.php +++ b/examples/svgRoundQuietzone.php @@ -65,7 +65,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{ $svg .= sprintf('%1$s%1$s', $this->options->eol); // transform to data URI only when not saving to file - if(!$saveToFile && $this->options->imageBase64){ + if(!$saveToFile && $this->options->outputBase64){ $svg = $this->toBase64DataURI($svg, 'image/svg+xml'); } @@ -325,7 +325,7 @@ $options->svgLogoCssClass = 'logo'; $options->version = 7; $options->eccLevel = EccLevel::H; $options->addQuietzone = false; // we're not adding a quiet zone, this is done internally in our own module -$options->imageBase64 = false; // avoid base64 URI output for the example +$options->outputBase64 = false; // avoid base64 URI output for the example $options->outputType = QROutputInterface::CUSTOM; $options->outputInterface = RoundQuietzoneSVGoutput::class; // load our own output class $options->drawLightModules = false; // set to true to add the light modules diff --git a/examples/svgWithLogo.php b/examples/svgWithLogo.php index 096b75948..87a041413 100644 --- a/examples/svgWithLogo.php +++ b/examples/svgWithLogo.php @@ -115,7 +115,7 @@ $options->svgLogoCssClass = 'dark'; $options->version = 5; $options->outputType = QROutputInterface::CUSTOM; $options->outputInterface = QRSvgWithLogo::class; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->eccLevel = EccLevel::H; // ECC level H is necessary when using logos $options->addQuietzone = true; $options->drawLightModules = true; diff --git a/examples/svgWithLogoAndCustomShapes.php b/examples/svgWithLogoAndCustomShapes.php index f8a1c9ac2..e2f3067ba 100644 --- a/examples/svgWithLogoAndCustomShapes.php +++ b/examples/svgWithLogoAndCustomShapes.php @@ -171,7 +171,7 @@ $options->version = 5; $options->quietzoneSize = 4; $options->outputType = QROutputInterface::CUSTOM; $options->outputInterface = QRSvgWithLogoAndCustomShapes::class; -$options->imageBase64 = false; +$options->outputBase64 = false; $options->eccLevel = EccLevel::H; // ECC level H is required when using logos $options->addQuietzone = true; diff --git a/src/Output/QRFpdf.php b/src/Output/QRFpdf.php index 5eb769fda..85d03c39b 100644 --- a/src/Output/QRFpdf.php +++ b/src/Output/QRFpdf.php @@ -143,7 +143,7 @@ class QRFpdf extends QROutputAbstract{ $this->saveToFile($pdfData, $file); - if($this->options->imageBase64){ + if($this->options->outputBase64){ $pdfData = $this->toBase64DataURI($pdfData, 'application/pdf'); } diff --git a/src/Output/QRGdImage.php b/src/Output/QRGdImage.php index ea8d472c6..05e5c2fa5 100644 --- a/src/Output/QRGdImage.php +++ b/src/Output/QRGdImage.php @@ -179,7 +179,7 @@ class QRGdImage extends QROutputAbstract{ $this->saveToFile($imageData, $file); - if($this->options->imageBase64){ + if($this->options->outputBase64){ $imageData = $this->toBase64DataURI($imageData, 'image/'.$this->options->outputType); } diff --git a/src/Output/QRImagick.php b/src/Output/QRImagick.php index 8e19d449d..9a20f4b32 100644 --- a/src/Output/QRImagick.php +++ b/src/Output/QRImagick.php @@ -135,7 +135,7 @@ class QRImagick extends QROutputAbstract{ $this->saveToFile($imageData, $file); - if($this->options->imageBase64){ + if($this->options->outputBase64){ $imageData = $this->toBase64DataURI($imageData, (new finfo(FILEINFO_MIME_TYPE))->buffer($imageData)); } diff --git a/src/Output/QRMarkupSVG.php b/src/Output/QRMarkupSVG.php index 12ff6e5a9..b8d2c3ac7 100644 --- a/src/Output/QRMarkupSVG.php +++ b/src/Output/QRMarkupSVG.php @@ -62,7 +62,7 @@ class QRMarkupSVG extends QRMarkup{ $svg .= sprintf('%1$s%1$s', $this->options->eol); // transform to data URI only when not saving to file - if(!$saveToFile && $this->options->imageBase64){ + if(!$saveToFile && $this->options->outputBase64){ $svg = $this->toBase64DataURI($svg, 'image/svg+xml'); } diff --git a/src/QROptionsTrait.php b/src/QROptionsTrait.php index a698f3749..a6e1fbc62 100644 --- a/src/QROptionsTrait.php +++ b/src/QROptionsTrait.php @@ -105,7 +105,7 @@ trait QROptionsTrait{ /** * Return the image resource instead of a render if applicable. - * This option overrides other output options, such as $cachefile and $imageBase64. + * This option overrides/ignores other output options, such as $cachefile and $outputBase64. * * Supported by the following modules: * @@ -127,10 +127,16 @@ trait QROptionsTrait{ protected ?string $cachefile = null; /** - * Toggle base64 or raw image data (if applicable) + * @deprecated 5.0.0 use QROptions::$outputBase64 instead + * @see \chillerlan\QRCode\QROptions::$outputBase64 */ protected bool $imageBase64 = true; + /** + * Toggle base64 data URI or raw data output (if applicable) + */ + protected bool $outputBase64 = true; + /** * Newline string */ @@ -530,4 +536,24 @@ trait QROptionsTrait{ $this->circleRadius = max(0.1, min(0.75, $circleRadius)); } + /** + * redirect call to the new variable + * + * @deprecated 5.0.0 use QROptions::$outputBase64 instead + * @see \chillerlan\QRCode\QROptions::$outputBase64 + */ + protected function set_imageBase64(bool $imageBase64):void{ + $this->outputBase64 = $imageBase64; + } + + /** + * redirect call to the new variable + * + * @deprecated 5.0.0 use QROptions::$outputBase64 instead + * @see \chillerlan\QRCode\QROptions::$outputBase64 + */ + protected function get_imageBase64():bool{ + return $this->outputBase64; + } + } diff --git a/tests/Data/QRDataTest.php b/tests/Data/QRDataTest.php index c82c0a499..be526f694 100644 --- a/tests/Data/QRDataTest.php +++ b/tests/Data/QRDataTest.php @@ -50,7 +50,7 @@ final class QRDataTest extends TestCase{ $this::assertSame(3, $matrix->getVersion()->getVersionNumber()); // attempt to read - $options->imageBase64 = false; + $options->outputBase64 = false; $options->readerUseImagickIfAvailable = false; $output = new QRGdImage($options, $matrix); diff --git a/tests/Output/QRMarkupTestAbstract.php b/tests/Output/QRMarkupTestAbstract.php index abe98301c..81ee3fbeb 100644 --- a/tests/Output/QRMarkupTestAbstract.php +++ b/tests/Output/QRMarkupTestAbstract.php @@ -43,7 +43,7 @@ abstract class QRMarkupTestAbstract extends QROutputTestAbstract{ * @inheritDoc */ public function testSetModuleValues():void{ - $this->options->imageBase64 = false; + $this->options->outputBase64 = false; $this->options->drawLightModules = true; $this->options->moduleValues = [ // data diff --git a/tests/Output/QROutputTestAbstract.php b/tests/Output/QROutputTestAbstract.php index 5df44c949..587a737d4 100644 --- a/tests/Output/QROutputTestAbstract.php +++ b/tests/Output/QROutputTestAbstract.php @@ -91,8 +91,8 @@ abstract class QROutputTestAbstract extends TestCase{ * coverage of the built-in output modules */ public function testRenderToCacheFile():void{ - $this->options->imageBase64 = false; - $this->outputInterface = new $this->FQN($this->options, $this->matrix); + $this->options->outputBase64 = false; + $this->outputInterface = new $this->FQN($this->options, $this->matrix); // create the cache file $file = $this->builddir.'/test.output.'.$this->type; $data = $this->outputInterface->dump($file); diff --git a/tests/QRCodeReaderTestAbstract.php b/tests/QRCodeReaderTestAbstract.php index e6b789cf5..8cc3ade03 100644 --- a/tests/QRCodeReaderTestAbstract.php +++ b/tests/QRCodeReaderTestAbstract.php @@ -96,8 +96,8 @@ abstract class QRCodeReaderTestAbstract extends TestCase{ } public function testReaderMultiMode():void{ - $this->options->outputType = QROutputInterface::GDIMAGE_PNG; - $this->options->imageBase64 = false; + $this->options->outputType = QROutputInterface::GDIMAGE_PNG; + $this->options->outputBase64 = false; $numeric = '123456789012345678901234567890'; $alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 $%*+-./:'; @@ -149,7 +149,7 @@ abstract class QRCodeReaderTestAbstract extends TestCase{ $this->options->imageTransparent = false; $this->options->eccLevel = $ecc->getLevel(); $this->options->version = $version->getVersionNumber(); - $this->options->imageBase64 = false; + $this->options->outputBase64 = false; // what's interesting is that a smaller scale seems to produce fewer reader errors??? // usually from version 20 up, independend of the luminance source // scale 1-2 produces none, scale 3: 1 error, scale 4: 6 errors, scale 5: 5 errors, scale 10: 10 errors diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php index eadee5fb2..a612d93e2 100755 --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -86,8 +86,8 @@ final class QRCodeTest extends TestCase{ * Tests if a cache file is properly saved in the given path */ public function testRenderToCacheFile():void{ - $this->options->cachefile = $this->builddir.'/test.cache.svg'; - $this->options->imageBase64 = false; + $this->options->cachefile = $this->builddir.'/test.cache.svg'; + $this->options->outputBase64 = false; // create the cache file $data = $this->qrcode->setOptions($this->options)->render('test');