1. Go to this page and download the library: Download zara-4/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zara-4 / php-sdk example snippets
use Zara4\API\Client;
$apiClient = new Client(API_CLIENT_ID, API_CLIENT_SECRET);
use Zara4\API\Client;
use Zara4\API\ImageProcessing\LocalImageRequest;
use Zara4\API\ImageProcessing\ProcessedImage;
$apiClient = new Client(API_CLIENT_ID, API_CLIENT_SECRET);
$originalImage = new LocalImageRequest("/path/to/original-image.jpg");
$processedImage = $apiClient->processImage($originalImage);
$apiClient->downloadProcessedImage($processedImage, "/where/to/save/compressed-image.jpg");
use Zara4\API\Client;
use Zara4\API\ImageProcessing\RemoteImageRequest;
use Zara4\API\ImageProcessing\ProcessedImage;
$apiClient = new Client(API_CLIENT_ID, API_CLIENT_SECRET);
$originalImage = new RemoteImageRequest("https://example.com/original-image.jpg");
$processedImage = $apiClient->processImage($originalImage);
$apiClient->downloadProcessedImage($processedImage, "/where/to/save/compressed-image.jpg");
use Zara4\API\Client;
use Zara4\API\ImageProcessing\CloudImageRequest;
use Zara4\API\ImageProcessing\ProcessedImage;
$apiClient = new Client(API_CLIENT_ID, API_CLIENT_SECRET);
$cloudDriveId = '905aaac0-06bb-11e7-83da-0b30de6ae4a2'; // Replace with your cloud drive id
$cloudFileId = '0B_x2cioi5h8IX1NwYkNDcE96Tlk'; // Replace with the id of the file you wish to compress
$originalImage = new CloudImageRequest($cloudDriveId, $cloudFileId);
$processedImage = $apiClient->processImage($originalImage);
$apiClient->downloadProcessedImage($processedImage, "/where/to/save/compressed-image.jpg");
use Zara4\API\Client;
use Zara4\API\ImageProcessing\LocalImageRequest;
$apiClient = new Client(API_CLIENT_ID, API_CLIENT_SECRET);
$originalImage = new LocalImageRequest("/path/to/original-image.jpg");
// Change request options
$originalImage->optimisationMode = OptimisationMode::HIGHEST;
$originalImage->outputFormat = OutputFormat::MATCH;
$originalImage->colourEnhancement = ColourEnhancement::IMPROVE_COLOUR;
$originalImage->resizeMode = ResizeMode::NONE;
$processedImage = $apiClient->processImage($originalImage);
$apiClient->downloadProcessedImage($processedImage, "/where/to/save/compressed-image.jpg");
$request = new \Zara4\API\ImageProcessing\LocalImageRequest('test-images/001.jpg');
// --- --- --- ---
// The id of the cloud storage drive to upload to (Replace with your cloud drive id)
// You can manage your Cloud Storage from https://zara4.com/account/cloud-storage
$destinationDriveId = '905aaac0-06bb-11e7-83da-0b30de6ae4a2';
// The name the uploaded file should be given on you Cloud Storage
$destinationFileName = 'YOUR FILE NAME';
// You can also specify the folder the compressed image should be uploaded to
// If you do not wish to specify a parent folder, set $destinationParentId = null
$destinationParentId = 'xxxxxxxxxxxxxxxxxxx';
$request->uploadToCloud($destinationDriveId, $destinationFileName, $destinationParentId);
// --- --- --- ---
$response = $this->client->processImage($request);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.