ubn5/backend/helpers/ThumbnailHelper.php

29 lines
746 B
PHP
Raw Permalink Normal View History

2025-02-10 05:21:56 +00:00
<?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]);
}
}
}
}