$this->image = imagecreatefromgif($this->filename); break; case 'image/jpeg': $this->image = imagecreatefromjpeg($this->filename); break; case 'image/png': $this->image = imagecreatefrompng($this->filename); break; default: throw new Exception('Invalid image: '.$this->filename); break; } } elseif (function_exists('getimagesizefromstring')) { $info = getimagesizefromstring($this->imagestring); } else { throw new Exception('PHP 5.4 is required to use method getimagesizefromstring'); } $this->original_info = array(
// Require GD library if (!extension_loaded('gd')) { throw new Exception('Required extension GD is not loaded.'); } $this->filename = $filename; return $this->get_meta_data(); } /** * Load a base64 string as image * * @param string $filename base64 string
* @return SimpleImage * @throws Exception * */ function __construct($filename = null, $width = null, $height = null, $color = null) { if ($filename) { $this->load($filename); } elseif ($width) { $this->create($width, $height, $color); } return $this; }
} } $image->writeImage($pathToSave); }else{ $image = new \abeautifulsite\SimpleImage($imagePath); if($size){ if($size['height'] && $size['width']){
$origin = $this->getPathToOrigin(); $filePath = $base.DIRECTORY_SEPARATOR. $sub.DIRECTORY_SEPARATOR.$this->urlAlias.$urlSize.'.'.pathinfo($origin, PATHINFO_EXTENSION);; if(!file_exists($filePath)){ $this->createVersion($origin, $size); if(!file_exists($filePath)){ throw new \Exception('Problem with image creating.'); } }
} return $filePath; } public function getContent($size = false){ return file_get_contents($this->getPath($size)); } public function getPathToOrigin(){ $base = $this->getModule()->getStorePath();
if($image->getExtension() != $dotParts[1]){ throw new \yii\web\HttpException(404, 'Image not found (extenstion)'); } if($image){ header('Content-Type: image/jpg'); echo $image->getContent($size); }else{ throw new \yii\web\HttpException(404, 'There is no images'); } } }
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); Yii::$app->controller = $oldController; return $result; } else { $id = $this->getUniqueId(); throw new InvalidRouteException('Unable to resolve the request "' . ($id === '' ? $route : $id . '/' . $route) . '".');
$params = $this->catchAll; unset($params[0]); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/../config/web.php'); (new yii\web\Application($config))->run();
$_GET = [ 'item' => 'Galery430', 'dirtyAlias' => 'c63842674f-1.png', ]; $_SERVER = [ 'REDIRECT_HTTPS' => 'On', 'REDIRECT_STATUS' => '200', 'HTTPS' => 'On', 'HTTP_HOST' => 'vnoviyvek.ru', 'HTTP_X_HTTPS' => '1', 'HTTP_X_FORWARDED_PROTO' => 'https', 'HTTP_CONNECTION' => 'close', 'HTTP_ACCEPT' => '*/*', 'HTTP_USER_AGENT' => 'claudebot', 'HTTP_REFERER' => 'http://vnoviyvek.ru/yii2images/images/image-by-item-and-alias.html?item=Galery430&dirtyAlias=c63842674f-1.png', 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'SERVER_SIGNATURE' => '', 'SERVER_SOFTWARE' => 'Apache/2.4.29', 'SERVER_NAME' => 'vnoviyvek.ru', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '3.237.178.126', 'DOCUMENT_ROOT' => '/home/c/cm56881/vnoviyvek/public_html', 'REQUEST_SCHEME' => 'http', 'CONTEXT_PREFIX' => '', 'CONTEXT_DOCUMENT_ROOT' => '/home/c/cm56881/vnoviyvek/public_html', 'SERVER_ADMIN' => 'info@timeweb.ru', 'SCRIPT_FILENAME' => '/home/c/cm56881/vnoviyvek/public_html/web/index.php', 'REMOTE_PORT' => '52608', 'REDIRECT_URL' => '/yii2images/images/image-by-item-and-alias.html', 'REDIRECT_QUERY_STRING' => 'item=Galery430&dirtyAlias=c63842674f-1.png', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.0', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'item=Galery430&dirtyAlias=c63842674f-1.png', 'REQUEST_URI' => '/yii2images/images/image-by-item-and-alias.html?item=Galery430&dirtyAlias=c63842674f-1.png', 'SCRIPT_NAME' => '/web/index.php', 'PHP_SELF' => '/web/index.php', 'REQUEST_TIME_FLOAT' => 1711649835.685, 'REQUEST_TIME' => 1711649835, 'argv' => [ 'item=Galery430&dirtyAlias=c63842674f-1.png', ], 'argc' => 1, ]; $_ENV = [ 'APACHE_CONFDIR' => '/etc/apache2-71', 'APACHE_RUN_DIR' => '/var/run/apache2-71', 'APACHE_PID_FILE' => '/var/run/apache2-71/apache2.pid', 'JOURNAL_STREAM' => '9:137677639', 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'INVOCATION_ID' => 'aa424722b23a4864b5f5ebfb9000e205', 'APACHE_LOCK_DIR' => '/var/lock/apache2-71', 'LANG' => 'C', 'APACHE_RUN_USER' => 'www-data', 'APACHE_RUN_GROUP' => 'www-data', 'APACHE_LOG_DIR' => '/var/log/apache2-71', 'PWD' => '/', ];