Image storing utility that will help you save images into defined storages.
$ composer require juniwalk/image-storage
extensions:
imageStorage: JuniWalk\ImageStorage\DI\ImageStorageExtension
imageStorage:
directory: /images # Relative to $wwwDir
allowOverwrite: TRUE
services:
imageStorage.storage.avatar:
class: JuniWalk\ImageStorage\Storages\LocalStorage(avatar, jpg)
setup:
- addFilter(JuniWalk\ImageStorage\Filters\ResizeFilter(512, 512, 'EXACT'))
- addFilter(JuniWalk\ImageStorage\Filters\WatermarkFilter(%wwwDir%/images/watermark.png))
/** @var JuniWalk\ImageStorage\Media */
$media = Media::fromImage(string $name, Nette\Utils\Image $image)
$media = Media::fromUpload(Nette\Http\FileUpload $fileUpload, string $name = NULL);
$media = Media::fromFile(string $filename);
$media = Media::fromString(string $name, string $content);
/** @var \JuniWalk\ImageStorage\ImageStorage */
$imageStorage = $this->getImageStorage();
/** @var string Relative path to $wwwDir */
$path = $imageStorage->store(string $storage, Media $media);