{ // provide compatibility with objects such as \SplFileInfo if (is_object($path) && method_exists($path, '__toString')) { $path = (string) $path; } $handle = @fopen($path, 'r'); if (false === $handle) { throw new InvalidArgumentException(sprintf('File %s does not exist.', $path)); } fclose($handle); return $path; } }
/** * {@inheritdoc} */ public function open($path) { $path = $this->checkPath($path); try { $imagick = new \Imagick($path); $image = new Image($imagick, $this->createPalette($imagick), $this->getMetadataReader()->readFile($path)); } catch (\Exception $e) { throw new RuntimeException(sprintf('Unable to open image %s', $path), $e->getCode(), $e);
if (is_resource($image)) { return static::getImagine()->read($image); } if (is_string($image)) { return static::getImagine()->open(Yii::getAlias($image)); } throw new InvalidParamException('File should be either ImageInterface, resource or a string containing file path.'); } /**
* @param int $height the height in pixels to create the thumbnail * @param string $mode mode of resizing original image to use in case both width and height specified * @return ImageInterface */ public static function thumbnail($image, $width, $height, $mode = ManipulatorInterface::THUMBNAIL_OUTBOUND) { $img = self::ensureImageInterfaceInstance($image); /** @var BoxInterface $sourceBox */ $sourceBox = $img->getSize(); $thumbnailBox = static::getThumbnailBox($sourceBox, $width, $height); if (self::isUpscaling($sourceBox, $thumbnailBox)) {
header("Content-Length: " . filesize($name)); // dump the picture and stop the script fpassthru($fp); exit; } Image::thumbnail('@webroot/'.$type.'/'.$image, $width, $height, \Imagine\Image\ManipulatorInterface::THUMBNAIL_INSET) ->save(Yii::getAlias('@webroot/'.$type.'/'.$width.'/'.$height.'/'.$image), ['quality' => 90])->show($ext); } exit(); // return $this->render('index'); }
$args = $this->controller->bindActionParams($this, $params); Yii::debug('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); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ 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__ . '/../../common/config/main.php', require __DIR__ . '/../../common/config/main-local.php', require __DIR__ . '/../config/main.php', require __DIR__ . '/../config/main-local.php' ); (new yii\web\Application($config))->run();
$_GET = [ 'type' => 'products', 'width' => '800', 'height' => '800', 'image' => '4921_sku_drevesnyy-napolnitel-dlya-koshachego-tualeta-super-cat-1.png', ];