fix
This commit is contained in:
@ -52,7 +52,7 @@ class CardFileService
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function createCardPNG(Card $card): false|string
|
||||
public static function createCardPNG(Card $card, bool $returnBase64 = false): false|string
|
||||
{
|
||||
if ($card->cardTemplate) {
|
||||
$formatter = BankFormatter::create();
|
||||
@ -65,7 +65,9 @@ class CardFileService
|
||||
$uploadDir = "/resources/cards/";
|
||||
$uploadDirUri = $uploadDir . mb_substr($newFileName, 0, 2) . '/' . mb_substr($newFileName, 2, 2) . '/';
|
||||
$oldMask = umask(0);
|
||||
mkdir(ROOT_DIR . $uploadDirUri, 0775, true);
|
||||
if (!file_exists(ROOT_DIR . $uploadDirUri)){
|
||||
mkdir(ROOT_DIR . $uploadDirUri, 0775, true);
|
||||
}
|
||||
umask($oldMask);
|
||||
$uploadFileDir = ROOT_DIR . $uploadDirUri;
|
||||
|
||||
@ -108,9 +110,14 @@ class CardFileService
|
||||
$cardSettings['qr_box_height'] ?? 135,
|
||||
100
|
||||
);
|
||||
$img->save($uploadFileDir . $newFileName);
|
||||
if ($returnBase64){
|
||||
return $img->getBase64();
|
||||
}
|
||||
else {
|
||||
$img->save($uploadFileDir . $newFileName);
|
||||
|
||||
return $uploadDirUri . $newFileName;
|
||||
return $uploadDirUri . $newFileName;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -39,7 +39,7 @@ $table->rows([
|
||||
$table->create();
|
||||
$table->render();
|
||||
|
||||
echo \kernel\helpers\Html::img(\kernel\app_modules\card\services\CardFileService::createCardPNG($card));
|
||||
echo \kernel\helpers\Html::img("data:image/png;base64, " . \kernel\app_modules\card\services\CardFileService::createCardPNG($card, true));
|
||||
|
||||
//$writer = new PngWriter();
|
||||
//
|
||||
|
@ -40,6 +40,17 @@ class ImageGD
|
||||
imagedestroy($this->img);
|
||||
}
|
||||
|
||||
public function getBase64(): string
|
||||
{
|
||||
ob_start ();
|
||||
imagepng($this->img);
|
||||
$image_data = ob_get_contents ();
|
||||
ob_end_clean ();
|
||||
|
||||
imagedestroy($this->img);
|
||||
return base64_encode ($image_data);
|
||||
}
|
||||
|
||||
public function makeCornersForImage($radius, $background): void
|
||||
{
|
||||
// включаем режим сопряжения цветов
|
||||
|
Reference in New Issue
Block a user