Update Upload.php

This commit is contained in:
Roman Kelesidis 2025-03-01 21:09:41 +03:00
commit 522d89993b

View file

@ -9,6 +9,9 @@
namespace TorrentPier\Common;
use claviska\SimpleImage;
use Exception;
/**
* Class Upload
* @package TorrentPier\Common
@ -165,14 +168,14 @@ class Upload
if (($this->cfg['max_width'] && $width > $this->cfg['max_width']) || ($this->cfg['max_height'] && $height > $this->cfg['max_height'])) {
for ($i = 0, $max_try = 3; $i <= $max_try; $i++) {
try {
$image = new \claviska\SimpleImage();
$image = new SimpleImage();
$image
->fromFile($this->file['tmp_name'])
->autoOrient()
->resize($this->cfg['max_width'], $this->cfg['max_height'])
->toFile($this->file['tmp_name']);
break;
} catch (\Exception $e) {
} catch (Exception $e) {
if ($i == $max_try) {
$this->errors[] = sprintf($lang['UPLOAD_ERROR_DIMENSIONS'], $this->cfg['max_width'], $this->cfg['max_height']);
return false;