PHP code example of ninjaimg / php-sdk

1. Go to this page and download the library: Download ninjaimg/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/ */

    

ninjaimg / php-sdk example snippets


$image = new \NinjaImg\NinjaUpload($ninjaImgDomain, $ninjaImgApiToken);
$content = file_get_contents('/path/to/my/image.jpg');
$newUrl = $image->upload($content, '/destination/path/file.jpg');

$image = new \NinjaImg\NinjaUpload($ninjaImgDomain, $ninjaImgApiToken);
$response = $image->delete('/destination/path/file.jpg');

$image = new \NinjaImg\NinjaUpload($ninjaImgDomain, $ninjaImgApiToken);
$response = $image->deleteBatch([
    '/destination/path/file1.jpg',
    '/destination/path/file2.jpg',
]);

$url = new \NinjaImg\NinjaImage('http://example.ninjaimg.com/destination/path/file.jpg');

return $url->height(200)->width(200)->getUrl();

$text = new \NinjaImg\NinjaText('example.ninjaimg.com');
$text->text('Hello world');

return $text->textFont('Arial')->getUrl();

composer