Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 /**
  *	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));
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 4
0
 /**
  *	Returns if the command is available on the system, relying on the
  *	'command' utility, which should be installed on most systems.
  *
  *	@return boolean True if it is available, otherwise false.
  */
 public function exists()
 {
     $Command = new Transformist_Command('command');
     $Result = $Command->execute(array('-v', $this->_name));
     return $Result->isSuccess();
 }
Ejemplo n.º 5
0
 /**
  *
  */
 public function testExecuteWithCustomAssignment()
 {
     $Command = new Transformist_Command('ls', '=');
     $this->assertEquals(new Transformist_CommandResult('ls --tabsize=5', array(), 0), $Command->execute(array('--tabsize' => 5)));
 }