Beispiel #1
0
 /**
  *	Converts the given document.
  *
  *	@param Transformist_Document $Document Document to convert.
  */
 public function convert(Transformist_Document $Document)
 {
     $input = $Document->input()->path();
     $output = $Document->output()->path();
     $ffmpeg = new Transformist_Command('ffmpeg');
     $params = array('-i' => $input, '-ar' => 44100, '-ab' => '64k', '-b' => 25, '-s' => '1280x1024', $output);
     $ffmpeg->execute($params);
 }
 /**
  *	Converts the given document.
  *
  *	@param Transformist_Document $Document Document to convert.
  */
 public function convert(Transformist_Document $Document)
 {
     $Input =& $Document->input();
     $input = Transformist_Registry::extension($Input->type());
     if (!empty($input)) {
         $input .= ':';
     }
     $input .= $Input->path();
     $Output =& $Document->output();
     $output = Transformist_Registry::extension($Output->type());
     if (!empty($output)) {
         $output .= ':';
     }
     $output .= $Output->path();
     $Convert = new Transformist_Command('convert');
     $Convert->execute(array($input, $output));
 }
Beispiel #3
0
 /**
  *	Converts the given document.
  *
  *	@param Transformist_Document $Document Document to convert.
  */
 public function convert(Transformist_Document $Document)
 {
     $Input =& $Document->input();
     $Output =& $Document->output();
     // The office command doesn't allow us to specify an output file name.
     // So here's the trick: we're creating a link to the input file, named
     // as the desired output file name, with a unique extension to ensure
     // that the link file name doesn't exists.
     // The we will pass the symlink to the office command, which will use
     // the link name as output file name.
     $inputPath = $Input->path();
     $workaround = $Input->baseName() !== $Output->baseName();
     if ($workaround) {
         $linkPath = $Output->dirPath() . DIRECTORY_SEPARATOR . $Output->baseName() . uniqid('.workaround-');
         if (symlink($inputPath, $linkPath)) {
             $inputPath = $linkPath;
         } else {
             return;
         }
     }
     //
     $arguments = array();
     if ($Output->type() == 'application/pdfa') {
         $arguments['-e'] = 'SelectPdfVersion=1';
     }
     $format = Transformist_Registry::extension($Output->type());
     if ($format) {
         $arguments['-f'] = $format;
     }
     $arguments += array('--output' => $Output->dirPath(), $inputPath);
     $Unoconv = new Transformist_Command('unoconv');
     $R = $Unoconv->execute($arguments);
     // We don't need the symlink anymore.
     if ($workaround) {
         unlink($inputPath);
     }
 }
Beispiel #4
0
 /**
  *
  */
 public function convert(Transformist_Document $Document)
 {
     file_put_contents($Document->output()->path(), file_get_contents($Document->input()->path()));
 }
 /**
  *	Finds and returns a chain of converters which can convert the given
  *	document.
  *
  *	@param Transformist_Document $Document Document to convert.
  *	@return array An array of converter names, or an empty array if no
  *		chain were found.
  */
 protected function _converterFor(Transformist_Document $Document)
 {
     $inputType = $Document->input()->type();
     $outputType = $Document->output()->type();
     $Converter = null;
     if (isset($this->_map[$inputType][$outputType])) {
         $Converter = $this->_ConverterCollection->get($this->_map[$inputType][$outputType]);
     }
     return $Converter;
 }