#108935 Исследовать вопрос с поддержкой альфа-канала при сохранении png-изображений стикеров

This commit is contained in:
Александр Рыбкин 2025-03-11 13:18:58 +03:00
parent 7ec9dd1e57
commit 92b2af6191
1 changed files with 3 additions and 3 deletions

View File

@ -178,9 +178,9 @@ class File extends \yii\db\ActiveRecord
$this->ext = $this->file->extension;
$this->md5 = md5_file($this->file->tempName);
$patch = $this->getDir(true);
if ($this->isImage && $this->ext != 'jpg') //не конвертируем изображение в jpg если оно уже jpg
if ($this->isImage && $this->ext != 'jpg' && $this->convertJpg) //не конвертируем изображение в jpg если оно уже jpg
{
$this->ext = $this->convertJpg ? 'jpg' : $this->ext;
$this->ext = 'jpg';
$this->name = $this->getFileName();
$fileName = $this->name . '.' . $this->ext;
@ -414,7 +414,7 @@ class File extends \yii\db\ActiveRecord
*/
protected function deleteBorder($filePatch)
{
$img = imagecreatefromjpeg($filePatch);
$img = $this->ext == 'jpg' ? imagecreatefromjpeg($filePatch) : imagecreatefrompng($filePatch);
$this->width = $this->width > 0 ? $this->width : imagesx($img);
$this->height = $this->height > 0 ? $this->height : imagesy($img);