vysokeskoly/image-api-sdk

SDK for Image Api

3.3.0 2024-10-17 11:09 UTC

This package is auto-updated.

Last update: 2024-12-17 11:30:22 UTC


README

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 ]