juniwalk/image-storage

This package is abandoned and no longer maintained. No replacement package was suggested.

Image storing utility that will help you save images into defined storages.

v1.0.0 2016-08-16 11:23 UTC

This package is auto-updated.

Last update: 2020-07-27 15:26:58 UTC


README

Travis GitHub Release Total Donwloads Code Quality Tests Coverage License

Image storing utility that will help you save images into defined storages.

Installation

$ composer require juniwalk/image-storage

Configuration

extensions:
	imageStorage: JuniWalk\ImageStorage\DI\ImageStorageExtension

imageStorage:
	directory: /images		# Relative to $wwwDir
	allowOverwrite: TRUE

Adding new storages

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))

Usage

/** @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);