Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

1
vendor/alchemy/ghostscript/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/vendor/

14
vendor/alchemy/ghostscript/.travis.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
language: php
before_script:
- sudo apt-get install -y ghostscript
- composer install --dev --prefer-source
php:
- 5.3.3
- 5.3
- 5.4
- 5.5
script:
- phpunit

22
vendor/alchemy/ghostscript/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,22 @@
CHANGELOG
---------
* 0.4.0 (06-25-2013)
* BC Break : Transcoder::create arguments have been inverted.
* BC Break : Service provider configuration has been updated.
* 0.3.0 (04-24-2013)
* Use Alchemy\BinaryDriver as driver base.
* BC Break : remove methods `open` and `close`. Methods `toImage` and `toPDF`
now take the input file as first argument.
* Code cleanup
* 0.2.0 (02-01-2013)
* Update API, BC break : rename PDFTranscoder to Transcoder
* 0.1.1 (11-27-2012)
* First stable version.

21
vendor/alchemy/ghostscript/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
Ghostscript-PHP is released with MIT License :
Copyright (c) 2012 Alchemy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

65
vendor/alchemy/ghostscript/README.md vendored Normal file
View File

@@ -0,0 +1,65 @@
# Ghostscript PHP driver
[![Build Status](https://secure.travis-ci.org/alchemy-fr/Ghostscript-PHP.png)](http://travis-ci.org/alchemy-fr/Ghostscript-PHP)
# API usage
To instantiate Ghostscript driver, the easiest way is :
```php
$transcoder = Ghostscript\Transcoder::create();
```
You can customize your driver by passing a `Psr\Log\LoggerInterface` or
configuration options.
Available options are :
- `gs.binaries` : the path (or an array of potential paths) to the ghostscript binary.
- `timeout` : the timeout for the underlying process.
```php
$transcoder = Ghostscript\Transcoder::create(array(
'timeout' => 42,
'gs.binaries' => '/opt/local/gs/bin/gs',
), $logger);
```
To process a file to PDF format, use the `toPDF` method :
Third and fourth arguments are respectively the first page and the number of
page to transcode.
```php
$transcoder->toPDF('document.pdf', 'first-page.pdf', 1, 1);
```
To render a file to Image, use the `toImage` method :
```php
$transcoder->toImage('document.pdf', 'output.jpg');
```
## Silex service provider :
A [Silex](silex.sensiolabs.org) Service Provider is available, all parameters
are optionals :
```php
$app = new Silex\Application();
$app->register(new Ghostscript\GhostscriptServiceProvider(), array(
'ghostscript.configuration' => array(
'gs.binaries' => '/usr/bin/gs',
'timeout' => 42,
)
'ghostscript.logger' => $app->share(function () {
return $app['monolog']; // use Monolog service provider
}),
));
$app['ghostscript.pdf-transcoder']->toImage('document.pdf', 'image.jpg');
```
# License
Released under the MIT License

View File

@@ -0,0 +1,33 @@
{
"name": "alchemy/ghostscript",
"type": "library",
"description": "Ghostscript PDF, a library to handle PDF through ghostscript",
"keywords": ["ghostscript", "pdf"],
"license": "MIT",
"authors": [
{
"name": "Romain Neutron",
"email": "imprec@gmail.com",
"homepage": "http://www.lickmychip.com/"
},
{
"name": "Phraseanet Team",
"email": "info@alchemy.fr",
"homepage": "http://www.phraseanet.com/"
}
],
"require": {
"php" : ">=5.3.3",
"alchemy/binary-driver" : "~1.5"
},
"require-dev": {
"phpunit/phpunit" : "~3.7",
"sami/sami" : "~1.0",
"silex/silex" : "~1.0"
},
"autoload": {
"psr-0": {
"Ghostscript" : "src"
}
}
}

1379
vendor/alchemy/ghostscript/composer.lock generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="display_errors" value="on"/>
</php>
<testsuites>
<testsuite name="Ghostscript Tests Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory>vendor</directory>
<directory>tests</directory>
</blacklist>
</filter>
</phpunit>

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Ghostscript-PHP.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ghostscript\Exception;
interface ExceptionInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Ghostscript-PHP.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ghostscript\Exception;
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

View File

@@ -0,0 +1,40 @@
<?php
/*
* This file is part of Ghostscript-PHP.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ghostscript;
use Silex\ServiceProviderInterface;
use Silex\Application;
class GhostscriptServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['ghostscript.default.configuration'] = array(
'gs.binaries' => array('gs'),
'timeout' => 60,
);
$app['ghostscript.configuration'] = array();
$app['ghostscript.logger'] = null;
$app['ghostscript.transcoder'] = $app->share(function(Application $app) {
$app['ghostscript.configuration'] = array_replace(
$app['ghostscript.default.configuration'], $app['ghostscript.configuration']
);
return Transcoder::create($app['ghostscript.configuration'], $app['ghostscript.logger']);
});
}
public function boot(Application $app)
{
}
}

View File

@@ -0,0 +1,108 @@
<?php
namespace Ghostscript;
use Alchemy\BinaryDriver\AbstractBinary;
use Psr\Log\LoggerInterface;
use Ghostscript\Exception\RuntimeException;
use Alchemy\BinaryDriver\Configuration;
use Alchemy\BinaryDriver\ConfigurationInterface;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
class Transcoder extends AbstractBinary
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'ghostscript-transcoder';
}
/**
* Transcode a PDF to an image.
*
* @param string $input The path to the input file.
* @param string $destinationThe path to the output file.
*
* @return Transcoder
*
* @throws RuntimeException In case of failure
*/
public function toImage($input, $destination)
{
try {
$this->command(array(
'-sDEVICE=jpeg',
'-dNOPAUSE',
'-dBATCH',
'-dSAFER',
'-sOutputFile=' . $destination,
$input,
));
} catch (ExecutionFailureException $e) {
throw new RuntimeException('Ghostscript was unable to transcode to Image', $e->getCode(), $e);
}
if (!file_exists($destination)) {
throw new RuntimeException('Ghostscript was unable to transcode to Image');
}
return $this;
}
/**
* Transcode a PDF to another PDF
*
* @param string $input The path to the input file.
* @param string $destination The path to the output file.
* @param integer $pageStart The number of the first page.
* @param integer $pageQuantity The number of page to include.
*
* @return Transcoder
*
* @throws RuntimeException In case of failure
*/
public function toPDF($input, $destination, $pageStart, $pageQuantity)
{
try {
$this->command(array(
'-sDEVICE=pdfwrite',
'-dNOPAUSE',
'-dBATCH',
'-dSAFER',
sprintf('-dFirstPage=%d', $pageStart),
sprintf('-dLastPage=%d', ($pageStart + $pageQuantity - 1)),
'-sOutputFile=' . $destination,
$input,
));
} catch (ExecutionFailureException $e) {
throw new RuntimeException('Ghostscript was unable to transcode to PDF', $e->getCode(), $e);
}
if (!file_exists($destination)) {
throw new RuntimeException('Ghostscript was unable to transcode to PDF');
}
return $this;
}
/**
* Creates a Transcoder.
*
* @param array|ConfigurationInterface $configuration
* @param LoggerInterface $logger
*
* @return Transcoder
*/
public static function create($configuration = array(), LoggerInterface $logger = null)
{
if (!$configuration instanceof ConfigurationInterface) {
$configuration = new Configuration($configuration);
}
$binaries = $configuration->get('gs.binaries', array('gs'));
return static::load($binaries, $logger, $configuration);
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace Ghostscript\Tests;
use Ghostscript\GhostscriptServiceProvider;
use Silex\Application;
use Symfony\Component\Process\ExecutableFinder;
class GhostscriptServiceProviderTest extends \PHPUnit_Framework_TestCase
{
public function testRegister()
{
$app = new Application;
$app->register(new GhostscriptServiceProvider());
$this->assertInstanceOf('\\Ghostscript\\Transcoder', $app['ghostscript.transcoder']);
}
public function testRegisterWithCustomTimeout()
{
$app = new Application;
$app->register(new GhostscriptServiceProvider(), array(
'ghostscript.configuration' => array(
'timeout' => 42
),
));
$this->assertEquals(42, $app['ghostscript.transcoder']->getProcessBuilderfactory()->getTimeout());
}
public function testRegisterWithCustomBinary()
{
$finder = new ExecutableFinder();
$MP4Box = $finder->find('MP4Box');
if (null === $MP4Box) {
$this->markTestSkipped('Unable to detect MP4Box, required for this test');
}
$app = new Application;
$app->register(new GhostscriptServiceProvider(), array(
'ghostscript.configuration' => array(
'gs.binaries' => $MP4Box
),
));
$this->assertEquals($MP4Box, $app['ghostscript.transcoder']->getProcessBuilderfactory()->getBinary());
}
public function testRegisterWithCustomLogger()
{
$logger = $this->getMock('Psr\Log\LoggerInterface');
$app = new Application;
$app->register(new GhostscriptServiceProvider(), array(
'ghostscript.logger' => $logger,
));
$this->assertEquals($logger, $app['ghostscript.transcoder']->getProcessRunner()->getLogger());
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Ghostscript\Tests;
use Ghostscript\Transcoder;
class TranscoderTest extends \PHPUnit_Framework_TestCase
{
protected $object;
protected function setUp()
{
$this->object = Transcoder::create();
}
public function testTranscodeToPdf()
{
$dest = tempnam(sys_get_temp_dir(), 'gs_temp') . '.pdf';
$this->object->toPDF(__DIR__ . '/../../files/test.pdf', $dest, 1, 1);
$this->assertTrue(file_exists($dest));
$this->assertGreaterThan(0, filesize($dest));
unlink($dest);
}
public function testTranscodeAIToImage()
{
$dest = tempnam(sys_get_temp_dir(), 'gs_temp') . '.jpg';
$this->object->toImage(__DIR__ . '/../../files/test.pdf', $dest);
$this->assertTrue(file_exists($dest));
$this->assertGreaterThan(0, filesize($dest));
unlink($dest);
}
}

View File

@@ -0,0 +1,4 @@
<?php
$loader = require __DIR__.'/../vendor/autoload.php';
$loader->add('Ghostscript\Tests', __DIR__);

File diff suppressed because one or more lines are too long

Binary file not shown.