PHP code example of rkcreative / aws-image-handler
1. Go to this page and download the library: Download rkcreative/aws-image-handler 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/ */
rkcreative / aws-image-handler example snippets
use Rkcreative\AwsImageHandler\Facades\ImageHandler;
$url = ImageHandler::resize(200, 200)->createUrl('path/to/image.jpg');
'providers' => [
// Other service providers...
Rkcreative\AwsImageHandler\AwsImageHandlerServiceProvider::class,
],
'aliases' => [
// Other aliases...
'ImageHandler' => Rkcreative\AwsImageHandler\Facades\ImageHandler::class,
],
use Rkcreative\AwsImageHandler\Services\ImageHandler;
$imageHandler = new ImageHandler();
$imageHandler->resize(200, 200);
// Generate the URL for the transformed image
$url = $imageHandler->createUrl('path/to/image.jpg');
use ImageHandler;
$url = ImageHandler::resize(200, 200)->createUrl('path/to/image.jpg');
$imageHandler = new ImageHandler();
$imageHandler->smartCrop($options);
$imageHandler->roundCrop($options);
// etc.
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Rkcreative\AwsImageHandler\Services\ImageHandler;
class ImageHandlerMacroServiceProvider extends ServiceProvider
{
public function boot()
{
// Sample blur image operation from the Sharp node.js image library to show how you could add it as a custom option.
ImageHandler::macro('blur', function ($blur) {
if ($blur < 0.3 || $blur > 1000) {
throw new \InvalidArgumentException('Invalid blur value. It must be = a sigma value between 0.3 and 1000.');
}
$this->options['blur'] = $blur;
return $this;
});
}
}
'providers' => [
// Other service providers...
App\Providers\ImageHandlerMacroServiceProvider::class,
],
$imageHandler = new ImageHandler();
$imageHandler->blur(3)->createUrl('path/to/image.jpg');