PHP code example of techart / image-service

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

    

techart / image-service example snippets


$manager = new \Techart\ImageService\Managers\InterventionImageManager();
$storage = \Techart\ImageService\Storages\StandardStorage::getInstance();
$config = [
    'sizes' => '*',
    'format' => [
        'webp',
        'jpg',
        'jpeg',
        'png',
        'gif',
    ],
    'methods' => [
        'resize',
        'crop',
        'fit',
    ]
];

$service = \Techart\ImageService\Service::getInstance($manager, $storage, $config);

    $imageUrl = $service->modify('путь до оригинальной картинки')
        ->setQuality(95)
        ->setSizes('800x600')
        ->setFormat('webp')
        ->setMethod('fit')
        ->process()
        ->getUrl()

$imageUrl = $service->modify('путь до оригинальной картинки', [
    'resize' => '400x0',
    'format' => 'webp',
    'quality' => 80,
    'method' => 'fit'
])->process()->getUrl()

$imageUrl = $service->setup('путь до оригинальной картинки', '/r/640x480/r/f/webp/f/q/80/q/m/fit/m')
    ->process()
    ->getUrl();

$originalImage = 'путь до оригинальной картинки';

$storage = $service->storage($originalImage);

if ($storage->haveModifyImages()) {
    $storage->delete(false);
}
gumlet/php-image-resize