public function getPathRelativeToRoot() : string
 {
     if (is_null($this->conversion)) {
         return $this->pathGenerator->getPath($this->media) . $this->media->file_name;
     }
     return $this->pathGenerator->getPathForConversions($this->media) . $this->conversion->getName() . '.' . $this->conversion->getResultExtension($this->media->extension);
 }
 /**
  * Get the path to the requested file relative to the root of the media directory.
  *
  * @return string
  */
 public function getPathRelativeToRoot()
 {
     $path = $this->media->id;
     if (is_null($this->conversion)) {
         return $path . '/' . $this->media->file_name;
     }
     return $path . '/conversions/' . $this->conversion->getName() . '.' . $this->conversion->getResultExtension($this->media->extension);
 }
 /**
  * Perform the conversion.
  *
  * @param \Spatie\MediaLibrary\Media $media
  * @param Conversion                 $conversion
  * @param string                     $copiedOriginalFile
  *
  * @return string
  */
 public function performConversion(Media $media, Conversion $conversion, $copiedOriginalFile)
 {
     $conversionTempFile = pathinfo($copiedOriginalFile, PATHINFO_DIRNAME) . '/' . string()->random(16) . $conversion->getName() . '.' . $media->extension;
     File::copy($copiedOriginalFile, $conversionTempFile);
     foreach ($conversion->getManipulations() as $manipulation) {
         (new GlideImage())->load($conversionTempFile, $manipulation)->useAbsoluteSourceFilePath()->save($conversionTempFile);
     }
     return $conversionTempFile;
 }
 /**
  * Perform the conversion.
  *
  * @param \Spatie\MediaLibrary\Media $media
  * @param Conversion $conversion
  * @param string $copiedOriginalFile
  *
  * @return string
  */
 public function performConversion(Media $media, Conversion $conversion, string $copiedOriginalFile)
 {
     $conversionTempFile = pathinfo($copiedOriginalFile, PATHINFO_DIRNAME) . '/' . string()->random(16) . $conversion->getName() . '.' . $media->extension;
     File::copy($copiedOriginalFile, $conversionTempFile);
     foreach ($conversion->getManipulations() as $manipulation) {
         GlideImage::create($conversionTempFile)->modify($manipulation)->save($conversionTempFile);
     }
     return $conversionTempFile;
 }
 public function convert(string $file, Conversion $conversion = null) : string
 {
     $imageFile = pathinfo($file, PATHINFO_DIRNAME) . '/' . pathinfo($file, PATHINFO_FILENAME) . '.jpg';
     $ffmpeg = FFMpeg::create(['ffmpeg.binaries' => config('laravel-medialibrary.ffmpeg_binaries'), 'ffprobe.binaries' => config('laravel-medialibrary.ffprobe_binaries')]);
     $video = $ffmpeg->open($file);
     $seconds = $conversion ? $conversion->getExtractVideoFrameAtSecond() : 0;
     $frame = $video->frame(TimeCode::fromSeconds($seconds));
     $frame->save($imageFile);
     return $imageFile;
 }
 /**
  * Add a conversion.
  *
  * @param string $name
  *
  * @return \Spatie\MediaLibrary\Conversion\Conversion
  */
 public function addMediaConversion($name)
 {
     $conversion = Conversion::create($name);
     $this->mediaConversions[] = $conversion;
     return $conversion;
 }