/** * Creates an image from a file. * * @param string $filePath * @param string $baseMime (image|video) * * @return null|string $thumnnailPath */ public function createFromFile($filePath, $baseMime, Workspace $workspace = null) { $ds = DIRECTORY_SEPARATOR; if (is_null($workspace)) { $prefix = $this->thumbDir; } else { $prefix = $this->thumbDir . $ds . $workspace->getCode(); if (!is_dir($prefix)) { @mkdir($prefix); } } $newPath = $prefix . $ds . $this->ut->generateGuid() . ".png"; $thumbnailPath = null; if ($baseMime === 'video') { try { $thumbnailPath = $this->creator->fromVideo($filePath, $newPath, 100, 100); } catch (\Exception $e) { $thumbnailPath = null; //error handling ? $thumbnailPath = null } } if ($baseMime === 'image') { try { $thumbnailPath = $this->creator->fromImage($filePath, $newPath, 100, 100); } catch (\Exception $e) { $thumbnailPath = null; //error handling ? $thumbnailPath = null } } return $thumbnailPath; }