/**
  * @return \Components\Point
  */
 public function position()
 {
     if (null === $this->m_position) {
         if (isset($this->initialized()->m_data['latitude']) && $this->m_data['longitude']) {
             $this->m_position = Point::of($this->m_data['latitude'], $this->m_data['longitude']);
         }
     }
     return $this->m_position;
 }
 public function render($panel_ = null)
 {
     /* @var $value \Components\Io_Image */
     if (($value = $this->value()) && $value->exists()) {
         $image = $value;
         $height = (int) $this->attribute('height');
         $width = (int) $this->attribute('width');
         if ($width || $height) {
             $dimensions = $value->getDimensions();
             if (!$width) {
                 $width = round($dimensions->x / ($dimensions->y / $height));
             } else {
                 if (!$height) {
                     $height = round($dimensions->y / ($dimensions->x / $width));
                 }
             }
             if ($this->embedded) {
                 $image = Io_Image::valueOf(Environment::pathResource('ui', 'image', 'tmp', $width, $height, $value->getName()));
                 if (false === $image->exists()) {
                     $value->scale(Point::of($width, $height));
                     $value->saveAs($image);
                 }
             }
         }
         $this->attribute('width', $width);
         $this->attribute('height', $height);
         if ($this->embedded) {
             $this->attribute('src', sprintf('data:%s;base64,%s', $image->getMimetype(), $image->getBase64()));
         } else {
             $this->attribute('src', (string) Media_Scriptlet_Engine::imageUri('thumbnail', $image->getPath(), $width, $height));
         }
     } else {
         if (null !== $value && Debug::active()) {
             Log::debug('components/ui/panel/image', 'Image for given location does not exist [%s].', $value);
         }
     }
     return parent::render();
 }
 /**
  * @param \Components\Http_Scriptlet_Context $context_
  * @param \Components\Uri $uri_
  */
 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $uri = $context_->getRequest()->getUri();
     $extension = $uri->getFileExtension();
     $name = $uri->getFilename(true);
     $uri_->popPathParam();
     $pathTarget = Environment::pathWeb() . $uri_->getPath() . '/' . \str\decodeUrl($name, true) . ".{$extension}";
     if (false === is_file($pathTarget)) {
         $fileTarget = Io::file($pathTarget);
         $directoryTarget = $fileTarget->getDirectory();
         if (false === $directoryTarget->exists()) {
             $directoryTarget->create();
         }
         $info = @json_decode(\str\decodeBase64Url($name));
         if (false === isset($info[0])) {
             throw new Http_Exception('media/scriptlet/engine', sprintf('Not found [%s].', $uri), Http_Exception::NOT_FOUND);
         }
         $pathSource = Environment::pathWeb($info[0]);
         if (false === is_file($pathSource)) {
             throw new Http_Exception('media/scriptlet/engine', sprintf('Not found [%s].', $uri), Http_Exception::NOT_FOUND);
         }
         if (isset($info[1]) || isset($info[2])) {
             if (!isset($info[1])) {
                 $info[1] = 0;
             }
             if (!isset($info[2])) {
                 $info[2] = 0;
             }
             Io::image($pathSource)->scale(Point::of($info[1], $info[2]))->saveAs($fileTarget);
         } else {
             Io::file($pathSource)->copy($fileTarget);
         }
     }
     header('Content-Length: ' . Io::fileSize($pathTarget)->bytes());
     readfile($pathTarget);
 }