null ); /** * * @var string */ protected $binary_name = 'GV_ffmpeg'; /** * * @param system_file $origine * @param string $dest * @return system_file */ protected function process(system_file $origine, $dest) { $this->log('GENERATING anim gif'); $tmpDir = $this->registry->get('GV_RootPath') . 'tmp/' . 'tmp' . time(); system_file::mkdir($tmpDir); $tmpDir = p4string::addEndSlash($tmpDir); $dimensions = $this->get_dimensions($origine, $this->options['size']); $newHeight = $dimensions['height']; $newWidth = $dimensions['width']; $system = system_server::get_platform(); if ($system == 'WINDOWS') { $cmd = $this->registry->get('GV_ffmpeg') . ' -i ' . $this->escapeshellargs($origine->getPathname()) . ' -s ' . $newWidth . 'x' . $newHeight . ' -r 1 -f image2 ' . $tmpDir . 'images%05d.jpg'; } else { $cmd = $this->binary . ' -i ' . $this->escapeshellargs($origine->getPathname()) . ' -s ' . $newWidth . 'x' . $newHeight . ' -r 1 -f image2 ' . $this->escapeshellargs($tmpDir) . 'images%05d.jpg'; } $this->shell_cmd($cmd); $files = array(); foreach (new RecursiveIteratorIterator( new RecursiveDirectoryIterator($tmpDir), RecursiveIteratorIterator::LEAVES_ONLY ) as $file) { if ($file->isDir() || strpos($file->getPathname(), '/.svn/') !== false) { continue; } if ($file->isFile()) { $filename = $file->getFilename(); $files[$filename] = $file->getPathname(); } } ksort($files); $n = count($files); $inter = round(count($files) / 10); $i = 0; foreach ($files as $k => $file) { if ($i % $inter !== 0) { if (unlink($file)) unset($files[$k]); } $i++; } $cmd = $this->registry->get('GV_imagick') . ' -delay 100 -loop 0 ' . $tmpDir . '*.jpg ' . $dest; $this->shell_cmd($cmd); foreach ($files as $file) unlink($file); rmdir($tmpDir); return $this; } }