forked from endroid/qr-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
184 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Endroid\QrCode\Writer; | ||
|
||
use Endroid\QrCode\Label\LabelInterface; | ||
use Endroid\QrCode\Logo\LogoInterface; | ||
use Endroid\QrCode\QrCodeInterface; | ||
use Endroid\QrCode\Writer\Result\GdResult; | ||
use Endroid\QrCode\Writer\Result\GifResult; | ||
use Endroid\QrCode\Writer\Result\ResultInterface; | ||
|
||
final class GifWriter extends AbstractGdWriter | ||
{ | ||
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface | ||
{ | ||
/** @var GdResult $gdResult */ | ||
$gdResult = parent::write($qrCode, $logo, $label, $options); | ||
|
||
return new GifResult($gdResult->getMatrix(), $gdResult->getImage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Endroid\QrCode\Writer\Result; | ||
|
||
use Endroid\QrCode\Matrix\MatrixInterface; | ||
|
||
class GdResult extends AbstractResult | ||
{ | ||
public function __construct( | ||
MatrixInterface $matrix, | ||
protected \GdImage $image | ||
) { | ||
parent::__construct($matrix); | ||
} | ||
|
||
public function getImage(): \GdImage | ||
{ | ||
return $this->image; | ||
} | ||
|
||
public function getString(): string | ||
{ | ||
throw new \Exception('You can only use this method in a concrete implementation'); | ||
} | ||
|
||
public function getMimeType(): string | ||
{ | ||
throw new \Exception('You can only use this method in a concrete implementation'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Endroid\QrCode\Writer\Result; | ||
|
||
use Endroid\QrCode\Matrix\MatrixInterface; | ||
|
||
final class WebPResult extends GdResult | ||
{ | ||
private int $quality; | ||
|
||
public function __construct(MatrixInterface $matrix, \GdImage $image, int $quality = -1) | ||
{ | ||
parent::__construct($matrix, $image); | ||
$this->quality = $quality; | ||
} | ||
|
||
public function getString(): string | ||
{ | ||
if (!function_exists('imagewebp')) { | ||
throw new \Exception('WebP support is not available in your GD installation'); | ||
} | ||
|
||
ob_start(); | ||
imagewebp($this->image, quality: $this->quality); | ||
|
||
return strval(ob_get_clean()); | ||
} | ||
|
||
public function getMimeType(): string | ||
{ | ||
return 'image/webp'; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.