diff --git a/File.php b/File.php index fdb7f1d..993b3de 100644 --- a/File.php +++ b/File.php @@ -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);