private function checkImageMagickComposite()
 {
     if (!isset($settings->options['binary_composite'])) {
         $this->binary_composite = ezcBaseFeatures::findExecutableInPath('composite');
     } else {
         if (file_exists($settings->options['binary_composite'])) {
             $this->binary_composite = $settings->options['binary_composite'];
         }
     }
     if ($this->binary_composite === null) {
         throw new ezcImageHandlerNotAvailableException('ezcImageImagemagickHandler', 'ImageMagick not installed or not available in PATH variable.');
     }
     // Prepare to run ImageMagick command
     $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
     // Open ImageMagick process
     $imageProcess = proc_open($this->binary_composite, $descriptors, $pipes);
     // Close STDIN pipe
     fclose($pipes[0]);
     $outputString = '';
     // Read STDOUT
     do {
         $outputString .= rtrim(fgets($pipes[1], 1024), "\n");
     } while (!feof($pipes[1]));
     $errorString = '';
     // Read STDERR
     do {
         $errorString .= rtrim(fgets($pipes[2], 1024), "\n");
     } while (!feof($pipes[2]));
     // Wait for process to terminate and store return value
     $return = proc_close($imageProcess);
     // Process potential errors
     if (strlen($errorString) > 0 || strpos($outputString, 'ImageMagick') === false) {
         throw new ezcImageHandlerNotAvailableException('ezcImageImagemagickHandler', 'ImageMagick not installed or not available in PATH variable.');
     }
 }
Ejemplo n.º 2
0
 /**
  * Compares to flash files comparing the output of `swftophp`
  * 
  * @param string $generated Filename of generated image
  * @param string $compare Filename of stored image
  * @return void
  */
 protected function swfCompare($generated, $compare)
 {
     $this->assertTrue(file_exists($generated), 'No image file has been created.');
     $this->assertTrue(file_exists($compare), 'Comparision image does not exist.');
     $executeable = ezcBaseFeatures::findExecutableInPath('swftophp');
     if (!$executeable) {
         $this->markTestSkipped('Could not find swftophp executeable to compare flash files. Please check your $PATH.');
     }
     $this->assertEquals($this->normalizeFlashCode(shell_exec($executeable . ' ' . escapeshellarg($compare))), $this->normalizeFlashCode(shell_exec($executeable . ' ' . escapeshellarg($generated))), 'Rendered image is not correct.');
 }
Ejemplo n.º 3
0
 /**
  * Compares to flash files comparing the output of `swftophp`
  * 
  * @param string $generated Filename of generated image
  * @param string $compare Filename of stored image
  * @return void
  */
 protected function swfCompare($generated, $compare)
 {
     $this->assertTrue(file_exists($generated), 'No image file has been created.');
     $this->assertTrue(file_exists($compare), 'Comparision image does not exist.');
     $executeable = ezcBaseFeatures::findExecutableInPath('swftophp');
     if (!$executeable) {
         $this->markTestSkipped('Could not find swftophp executeable to compare flash files. Please check your $PATH.');
     }
     $generatedCode = shell_exec($executeable . ' ' . escapeshellarg($generated));
     $compareCode = shell_exec($executeable . ' ' . escapeshellarg($compare));
     foreach (array('generatedCode' => $generatedCode, 'compareCode' => $compareCode) as $var => $content) {
         $content = preg_replace('/\\$[sf]\\d+/', '$var', $content);
         $content = preg_replace('[/\\*.*\\*/]i', '/* Comment irrelevant */', $content);
         ${$var} = $content;
     }
     $this->assertEquals($generatedCode, $compareCode, 'Rendered image is not correct.');
 }