-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update iloveimg-php library to V1.1.16
- Loading branch information
Diego Orellano
authored and
Diego Orellano
committed
Oct 30, 2023
1 parent
d5ddfb3
commit 1deb66c
Showing
26 changed files
with
809 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
Oops, something went wrong.