Пример #1
0
 /**
  * @param KrakenOptions $options
  * @param KrakenImage   $image
  *
  * @return CompressResponse
  */
 public static function fromFile(KrakenOptions $options, KrakenImage $image)
 {
     $apiEndpoint = sprintf('%s/upload', self::API_URL);
     $file = class_exists('CURLFile') ? new \CURLFile($image->getPath()) : sprintf('@%s', $image->getPath());
     $curl = new Curl();
     $curl->post($apiEndpoint, ['file' => $file, 'data' => json_encode($options->getConfiguredOptions())]);
     return self::parseResponse($curl);
 }
Пример #2
0
 public function testConvertToAndKeepExtension()
 {
     $krakenOptions = new KrakenOptions('fake_key', 'fake_secret');
     $krakenOptions->convertTo('gif', '#B4DA55', true);
     $this->assertEquals(['auth' => ['api_key' => 'fake_key', 'api_secret' => 'fake_secret'], 'convert' => ['format' => 'gif', 'background' => '#B4DA55', 'keep_extension' => true], 'wait' => true], $krakenOptions->getConfiguredOptions());
 }