https://github.com/yiimaker/yii2-imagable
Image saving extension for yii2
https://github.com/yiimaker/yii2-imagable
gd image imagemagick yii2-extension
Last synced: about 2 months ago
JSON representation
Image saving extension for yii2
- Host: GitHub
- URL: https://github.com/yiimaker/yii2-imagable
- Owner: yiimaker
- License: bsd-3-clause
- Created: 2016-12-04T16:05:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-28T11:34:45.000Z (about 8 years ago)
- Last Synced: 2025-02-09T21:12:01.251Z (3 months ago)
- Topics: gd, image, imagemagick, yii2-extension
- Language: PHP
- Size: 224 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#Instalation
```
php composer.phar require yiimaker/yii2-imagable
```
or add```json
"yiimaker/yii2-imagable": "*"
```
to the `require` section of your composer.json.
#Confiugation
After extension is installed you need to setup imagable application component:
```php
'imagable' => [
'class' => 'ymaker\imagable\Imagable',
'imageClass' => 'ymaker\imagable\instances\CreateImageImagine',
'categories' => [
'origin' => false,
'category' => [
'galery' => [
'origin' => true,
],
'galery/more' => [
'origin' => false,
],
'avatars' => [
'size' => [
'big' => [
'width' => 1000,
'height' => 500,
]
]
]
]
]
...
```#Usage
###Create image
```php
$imageName = \Yii::$app->imagable->create('avatars', 'pathToImage');
// Or
$imageName = \Yii::$app->imagable->createMultiply(['avatars', 'galery/more'], 'pathToImage');
```###Get Image
```php
$fullPathToImage = \Yii::$app->imagable->get('avatars', 'big', $imageName);
```###Delete Image
```php
$isDeleted = \Yii::$app->imagable->delete('avatars', $imageName);
```###Data provider
```php
//To action
/** @var Imagable $image */
$imagable = \Yii::$app->imagable;
$imagable->dataProvider = [
'key' => $data
];
//...//To class
class ImageClass extends Object implements CreateImageInterface
{
public $dataProvider;
public function init()
{
parent::init(); // TODO: Change the autogenerated stub
echo $this->dataProvider['key'];
}
//...
}
```