PHP code example of inteve / simple-image-storage
1. Go to this page and download the library: Download inteve/simple-image-storage 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/ */
inteve / simple-image-storage example snippets php
$image = $imageStorage->upload($fileUpload);
// $image = 'image-name.jpg'
$avatar = $imageStorage->upload($fileUpload, 'upload/avatars');
// $avatar = 'upload/avatars/image-name.jpg';
php
$imageStorage->delete('upload/avatar/image-name.jpg');
php
$path = $imageStorage->getRealPath('upload/avatar/image-name.jpg');
php
$path = $imageStorage->getPublicPath('upload/avatar/image-name.jpg');
php
$path = $imageStorage->thumbnail($file, $width, $height, $flags = NULL, $quality = NULL);
$path = $imageStorage->thumbnail('upload/avatar/image-name.jpg', 512, 256);
php
$imageStorage = new ImageStorage(..., ..., ..., function ($sourcePath, $outputPath, array $thumbnailData) {
$im = new Imagick;
$im->readImage($sourcePath);
$im->crop(...);
$im->writeImage($outputPath);
});
php
class BasePresenter extends Nette\Application\UI\Presenter
{
/** @var Inteve\SimpleImageStorage\ImageStorage @inject */
public $imageStorage;
protected function beforeRender()
{
parent::beforeRender();
$this->template->img = $this->imageStorage;
}
}