PHP code example of ingowalther / image-minify-php-client

1. Go to this page and download the library: Download ingowalther/image-minify-php-client 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/ */

    

ingowalther / image-minify-php-client example snippets


$client = new \IngoWalther\ImageMinifyPhpClient\Client\ImageMinifyApiClient($serverUrl, $apiKey);

/** @var \IngoWalther\ImageMinifyPhpClient\Response\CompressedImage $compressedImage */
$compressedImage  = $client->getCompressedImage($imagePath);

// The size before compression
$oldSize = $compressedImage->oldSize;

// The size after compression
$newSize = $compressedImage->newSize;

// The saving in percent
$saving = $compressedImage->saving;

// The binary-content of the compressed image
$binaryContent = $compressedImage->binaryContent;

$success = $client->writeCompressedImage($imagePath, $newImagePath);