29 lines
746 B
PHP
29 lines
746 B
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Created by HanumanIT Co.,Ltd.
|
||
|
|
* User: kongoon
|
||
|
|
* Date: 2019-07-09
|
||
|
|
* Time: 23:43
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace backend\helpers;
|
||
|
|
|
||
|
|
|
||
|
|
use Imagine\Image\Box;
|
||
|
|
use Yii;
|
||
|
|
use yii\imagine\Image;
|
||
|
|
|
||
|
|
class ThumbnailHelper
|
||
|
|
{
|
||
|
|
public static function createThumbnail($event) {
|
||
|
|
//Yii::info($event->fileName); // $event->fileName contains filesystem full path to file
|
||
|
|
// Some thumbnail operations
|
||
|
|
if(isset($event->fileName)) {
|
||
|
|
$f = explode('.', $event->fileName);
|
||
|
|
$extension = end($f);
|
||
|
|
if($extension != 'pdf' && $extension != 'PDF') {
|
||
|
|
Image::getImagine()->open($event->fileName)->thumbnail(new Box(1024, 1024))->save($event->fileName, ['quality' => 100]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|