/**
  * Create a new HTTP client
  */
 private function createClient()
 {
     $this->imbo = ImboClient::factory(['serverUrls' => [$this->params['url']], 'publicKey' => 'publickey', 'privateKey' => 'privatekey', 'user' => 'user']);
     $eventDispatcher = $this->imbo->getEventDispatcher();
     $eventDispatcher->addSubscriber($this->history);
     $defaultHeaders = ['X-Test-Session-Id' => self::$testSessionId];
     $this->imbo->setDefaultHeaders($defaultHeaders);
 }
 public function register(Application $app)
 {
     $app['imbo.serverUrls'] = array();
     $app['imbo.publicKey'] = '';
     $app['imbo.privateKey'] = '';
     $app['imbo.user'] = '';
     $app['imbo'] = $app->share(function () use($app) {
         return ImboClient::factory(array('serverUrls' => $app['imbo.serverUrls'], 'publicKey' => $app['imbo.publicKey'], 'privateKey' => $app['imbo.privateKey'], 'user' => $app['imbo.user'] ?: $app['imbo.publicKey']));
     });
 }
Example #3
0
 public function init()
 {
     if (!$this->serverUrl) {
         throw new Exception('Not set servers!');
     }
     if (!$this->imageDomain) {
         throw new Exception('Not set domain for image!');
     }
     $this->_client = ImboClient::factory(['serverUrls' => (array) $this->serverUrl, 'publicKey' => $this->publicKey, 'privateKey' => $this->privateKey, 'user' => $this->user]);
 }
 public function testCanDeleteAccessControlRule()
 {
     $this->setMockResponse($this->client, 'acl_rule_deleted');
     $response = $this->client->deleteAccessControlRule('some-public-key', 'bf1942');
     $requests = $this->getMockedRequests();
     $request = $requests[0];
     $this->assertSame('DELETE', $request->getMethod());
     $this->assertSame('http://imbo/keys/some-public-key/access/bf1942', urldecode($request->getUrl()));
     $this->assertSame('christer', (string) $request->getHeader('x-imbo-publickey'));
     $this->assertTrue($request->hasHeader('X-Imbo-Authenticate-Signature'));
 }
Example #5
0
<?php

require __DIR__ . '/vendor/autoload.php';
$config = (require __DIR__ . '/config/config.php');
use ImboClient\ImboClient;
use ImboClient\ImagesQuery;
$client = ImboClient::factory($config);
$query = (new ImagesQuery())->limit($config['numImages']);
$response = $client->getImages($query);
$bytes = [];
$start = time();
$i = 0;
for ($x = 0; $x < $config['iterations']; $x++) {
    foreach ($response['images'] as $image) {
        $url = $client->getImageUrl($image['imageIdentifier'])->{$config['transformation']}($config['size'][0], $config['size'][1])->convert($config['format']);
        $bytes[] = strlen($client->getImageDataFromUrl($url));
        echo '.';
        if (++$i === 50) {
            $i = 0;
            echo PHP_EOL;
        }
    }
}
echo PHP_EOL;
echo 'Resized ' . count($bytes) . ' images in ' . (time() - $start) . 's' . PHP_EOL;