PHP code example of outerweb / image-library

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

    

outerweb / image-library example snippets


use OuterWeb\ImageLibrary\Facades\ImageLibrary;
use OuterWeb\ImageLibrary\Entities\AspectRatio;
use OuterWeb\ImageLibrary\Entities\ConversionDefinition;
use OuterWeb\ImageLibrary\Entities\Effects;

ImageLibrary::addConversionDefinition(
    ConversionDefinition::make()
        ->name('thumbnail')
        ->label('Thumbnail')
        ->translateLabel()
        ->aspectRatio(
            AspectRatio::make()
                ->x(1)
                ->y(1)
        )
        ->defaultWidth(100)
        ->defaultHeight(100)
        ->effects(
            Effects::make()
                ->blur(10)
                ->pixelate(10)
                ->greyscale()
                ->sepia()
                ->sharpen(10)
        )
        ->createSync()
);

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->name('thumbnail');

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->label('Thumbnail');

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->label('conversions.labels.thumbnail');
    ->translateLabel();

use OuterWeb\ImageLibrary\Entities\AspectRatio;
use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->aspectRatio(
        AspectRatio::make()
            ->x(1)
            ->y(1)
    );

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->aspectRatio('16:9');

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->aspectRatio([16, 9]);

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->defaultWidth(100)
    ->defaultHeight(100);

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;
use OuterWeb\ImageLibrary\Entities\Effects;

ConversionDefinition::make()
    ->effects(
        Effects::make()
            ->blur(10)
            ->pixelate(10)
            ->greyscale()
            ->sepia()
            ->sharpen(10)
    );

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->effects([
        'blur' => 10,
        'pixelate' => 10,
        'greyscale' => true,
        'sepia' => true,
        'sharpen' => 10
    ]);

use OuterWeb\ImageLibrary\Entities\ConversionDefinition;

ConversionDefinition::make()
    ->createSync();

use OuterWeb\ImageLibrary\Facades\ImageLibrary;

$image = ImageLibrary::upload($request->file('image'));

use OuterWeb\ImageLibrary\Facades\ImageLibrary;

$image = ImageLibrary::upload($request->file('image'), 's3');

use OuterWeb\ImageLibrary\Facades\ImageLibrary;

$image = ImageLibrary::upload($request->file('image'), 's3', [
    'title' => 'My image',
    'alt' => 'This is my image'
]);

use OuterWeb\ImageLibrary\Facades\ImageLibrary;

$image = ImageLibrary::upload($request->file('image'), 's3', [
    'title' => [
        'en' => 'My image',
        'nl' => 'Mijn afbeelding'
    ],
    'alt' => [
        'en' => 'This is my image',
        'nl' => 'Dit is mijn afbeelding'
    ]
]);
bash
php artisan image-library:install