/** * Resize an image using the computed settings. * * @param \Torann\MediaSort\File\UploadedFile $file * @param \stdClass $style * * @return string */ public function resize(UploadedFile $file, $style) { $filePath = tempnam(sys_get_temp_dir(), 'STP') . '.' . $file->getClientOriginalName(); list($width, $height, $option) = $this->parseStyleDimensions($style); $method = "resize" . ucfirst($option); if ($method == 'resizeCustom') { $this->resizeCustom($file, $style->value)->save($filePath, ['quality' => $this->quality]); } else { $this->{$method}($file, $width, $height)->save($filePath, ['quality' => $this->quality]); } return $filePath; }
/** * Mutator method for the uploadedFile property. * * @param mixed $uploadedFile * @param string $styleName * * @return void */ public function setUploadedFile($uploadedFile, $styleName) { $this->clear(); if ($uploadedFile == MEDIASORT_NULL) { return; } $this->uploadedFile = $this->fileManager->make($uploadedFile); $this->instanceWrite('file_name', $this->uploadedFile->getClientOriginalName()); $this->instanceWrite('file_size', $this->uploadedFile->getClientSize()); $this->instanceWrite('content_type', $this->uploadedFile->getMimeType()); $this->instanceWrite('updated_at', date('Y-m-d H:i:s')); $this->queueAllForWrite(); }