Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use MikeyMike\Kraken\KrakenOptions;
use MikeyMike\Kraken\Request\Compress;
use MikeyMike\Kraken\KrakenImage;
$options = new KrakenOptions('api_key', 'api_secret');
// Configure Options
$options->useDevelopment();
$response = Compress::fromFile($options, KrakenImage::fromPath('kraken-logo.png'));
var_dump($krakenResponse);