/** * @inheritdoc */ public function format($readFilePath) { $tmpFilePath = FileSystemHelper::getNewTempFilename($this->type); PdfHelper::savePreview($readFilePath, $tmpFilePath); return $tmpFilePath; }
/** * Rotates image if need. * @param string $readFilePath path to file that must be checked and rotated (if need). * @param string|null|false $extension extension for new temp file. * Default is false, meaning extension must be parsed from `$readFilePath` file. * @return string|null new temp file path, or null if rotating is not necessary. */ protected function rotateImage($readFilePath, $extension = false) { try { $result = ImageHelper::normalizeRotating($readFilePath); if (!$result) { return null; } if ($extension === false) { $extension = $this->parseFileExtension($readFilePath); } $tempFile = FileSystemHelper::getNewTempFilename($extension); $result->save($tempFile, $this->saveOptions); return $tempFile; } catch (\Exception $ex) { Yii::error('Cannot normalize rotating. ' . ErrorHandler::convertExceptionToString($ex), __METHOD__); return null; } }