Skip to content

vysokeskoly/image-api-sdk

Repository files navigation

VysokeSkoly / ImageApiSdk

Latest Stable Version License Checks Build Coverage Status

Sdk for ImageApi

Installation

{
    "vysokeskoly/image-api-sdk": "^3.0"
}

Requirements

  • PHP 8.1
  • Corresponding version of ImageApi

Usage

In Symfony application

services:
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    VysokeSkoly\ImageApi\Sdk\ImageUploaderInterface: '@VysokeSkoly\ImageApi\Sdk\ImageApiUploader'

    VysokeSkoly\ImageApi\Sdk\Service\ApiProvider:
        $apiUrl: '%image_api_url%'
        $apiKey: '%image_api_key%'
        $namespace: '%image_api_namespace%'

    VysokeSkoly\ImageApi\Sdk\Service\CommandQueryFactory: ~

    VysokeSkoly\ImageApi\Sdk\ImageApiUploader:
        arguments:
            $allowedMimeTypes:
                GIF: 'image/gif'
                JPEG: 'image/jpeg'
                PNG: 'image/png'
            $imageMaxFileSize: 8536064 # 8 * 1024 * 124 = 8 MB
            $imageMaxSize: 2048
        calls:
            - [ enableCache ]

    # optional
    VysokeSkoly\ImageApi\Sdk\Service\SavedImageDecoder:
        arguments:
            $imageBaseUrl: '%image_api_url%'
        tags:
            - { name: lmc_cqrs.response_decoder, priority: 55 }

NOTE: If you need size information about just Saved images, you need to enable Image Cache for a decoder.

\VysokeSkoly\ImageApi\Sdk\Service\ImagesCache::enable();

or in services declaration

    VysokeSkoly\ImageApi\Sdk\ImageApiUploader:
        ...
        calls:
            - [ enableCache ]