Skip to content

Commit

Permalink
Update iloveimg-php library to V1.1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Orellano authored and Diego Orellano committed Oct 30, 2023
1 parent d5ddfb3 commit 1deb66c
Show file tree
Hide file tree
Showing 26 changed files with 809 additions and 40 deletions.
3 changes: 1 addition & 2 deletions iloveimg-php/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once __DIR__ . '/src/Request/Response.php';
require_once __DIR__ . '/src/Request/Request.php';
require_once __DIR__ . '/src/Request/Body.php';

require_once __DIR__ . '/src/Element.php';
//Exceptions
require_once __DIR__ . '/src/Exceptions/ExtendedException.php';
require_once __DIR__ . '/src/Exceptions/DownloadException.php';
Expand All @@ -20,7 +20,6 @@
//Iloveimg
require_once __DIR__ . '/src/Iloveimg.php';
require_once __DIR__ . '/src/ImageTask.php';
require_once __DIR__ . '/src/Element.php';

//Specific processes
require_once __DIR__ . '/src/CompressImageTask.php';
Expand Down
4 changes: 2 additions & 2 deletions iloveimg-php/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PHP 7.1 and later.
You can install the library via [Composer](http://getcomposer.org/). Run the following command:

```bash
composer require iloveimg/iloveimg-php
composer require ilovepdf/iloveimg-php
```

To use the library, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading):
Expand Down Expand Up @@ -59,4 +59,4 @@ See samples folder.

## Documentation

Please see https://developer.iloveimg.com/docs for up-to-date documentation.
Please see https://developer.iloveimg.com/docs for up-to-date documentation.
34 changes: 34 additions & 0 deletions iloveimg-php/samples/chained_task.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\Iloveimg;


//this is a sample for a chined task. You can perform multiple tasks on a files uploading just once.

// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$iloveimg = new Iloveimg('project_public_id','project_secret_key');

$rotateTask = $iloveimg->newTask('rotate');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $rotateTask->addFile('/path/to/file/document.jpg');
$file->setRotation(90);

// run the task
$rotateTask->execute();

//and create a new task from last action
$compressTask = $rotateTask->next('compress');
$compressTask->setCompressionLevel('extreme');

// process files
$compressTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$compressTask->download();
33 changes: 33 additions & 0 deletions iloveimg-php/samples/compress_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');


use Iloveimg\CompressImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new CompressImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');

// we can set rotate to file
$file->setRotation(90);

// set compression level
$myTask->setCompressionLevel('extreme');

// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('lowlow_compression');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download('path/to/download');
22 changes: 22 additions & 0 deletions iloveimg-php/samples/compress_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\CompressImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new CompresImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download();
26 changes: 26 additions & 0 deletions iloveimg-php/samples/get_remaining_files.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\Iloveimg;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$iloveimg = new Iloveimg('project_public_id', 'project_secret_key');


//get remaining files
$remainingFiles = $iloveimg->getRemainingFiles();


//print your remaining files
echo $remainingFiles;

//only start new process if you have enough files
if($remainingFiles>0) {
//start the task
$myTask = $iloveimg->newTask('merge');
}
27 changes: 27 additions & 0 deletions iloveimg-php/samples/repair_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\RepairImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new RepairImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');


// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('repaired_file');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download('path/to/download');
22 changes: 22 additions & 0 deletions iloveimg-php/samples/repair_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\RepairImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new RepairImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download();
41 changes: 41 additions & 0 deletions iloveimg-php/samples/resize_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\ResizeImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new ResizeImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');


//set resize mode to pixels
$myTask->setResizeMode('pixels');

//resize to fit into a 1024px square
$myTask->setPixelsWidth('1024');
$myTask->setPixelsHeight('1024');

//do not make it bigger
$myTask->setNoEnlargeIfSmaller(true);

//queep relation
$myTask->setMaintainRatio(true);


// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('repaired_file');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download('path/to/download');
26 changes: 26 additions & 0 deletions iloveimg-php/samples/resize_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\ResizeImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new ResizeImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');

//set resize mode to percentage and resize 50%
$myTask->setResizeMode('percentage');
$myTask->setPercentage('50');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download();
29 changes: 29 additions & 0 deletions iloveimg-php/samples/rotate_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\RotateImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new RotateImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');

// set the rotation, in degrees
$file->setRotation(90);

// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('rotated_file');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download('path/to/download');
25 changes: 25 additions & 0 deletions iloveimg-php/samples/rotate_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\RotateImageTask;


// you can call task class directly
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$myTask = new RotateImageTask('project_public_id','project_secret_key');

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');

// set the rotation, in degrees
$file->setRotation(90);

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download();
54 changes: 54 additions & 0 deletions iloveimg-php/samples/try_catch_errors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');
//if manual installation has been used comment line that requires the autoload and uncomment this line:
//require_once('../init.php');

use Iloveimg\Iloveimg;
use Iloveimg\CompressimageImageTask;


try {
// start the manager classy
// to get your key pair, please visit https://developer.iloveimg.com/user/projects
$iloveimg = new Iloveimg('project_public_id','project_secret_key');

// and get the task tool
$myTask = $iloveimg->newTask('compress');

// or you can call task class directly, this set the same tool as before
$myTask = new \Iloveimg\CompressimageImageTask('project_public_id','project_secret_key');


// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.jpg');
$file2 = $myTask->addFile('/path/to/file/document2.jpg');

// and set name for output file.
// in this case it will output a zip file, so we set the package name.
$myTask->setPackagedFilename('compress_documents');

// and name for splitted document (inside the zip file)
$myTask->setOutputFilename('compressed');

// process files
$myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download('path/to/download');

} catch (\Iloveimg\Exceptions\StartException $e) {
echo "An error occured on start: " . $e->getMessage() . " ";
} catch (\Iloveimg\Exceptions\AuthException $e) {
echo "An error occured on auth: " . $e->getMessage() . " ";
echo implode(', ', $e->getErrors());
} catch (\Iloveimg\Exceptions\UploadException $e) {
echo "An error occured on upload: " . $e->getMessage() . " ";
echo implode(', ', $e->getErrors());
} catch (\Iloveimg\Exceptions\ProcessException $e) {
echo "An error occured on process: " . $e->getMessage() . " ";
echo implode(', ', $e->getErrors());
} catch (\Exception $e) {
echo "An error occured: " . $e->getMessage();
}
Loading

0 comments on commit 1deb66c

Please sign in to comment.