Example #1
0
 /**
  * Intialize descriptor from an existing descriptor file
  *
  * @param string $source
  * 
  * @return Deepzoom\Descriptor Fluent interface
  * @throw InvalidArgumentExceptioncheck pyramid level
  */
 public function open($source)
 {
     if ($this->_streamWrapper->exists($source)) {
         /**
          * @var $xml SimpleXMLElement
          */
         $xml = simplexml_load_string($this->_streamWrapper->getContents($source), null, LIBXML_NOERROR);
         if ($xml !== false) {
             $this->_width = (int) $xml->Size["Width"];
             $this->_height = (int) $xml->Size["Height"];
             $this->_tileSize = (int) $xml["TileSize"];
             $this->_tileOverlap = (int) $xml["Overlap"];
             $this->_tileFormat = (string) $xml["Format"];
         } else {
             throw new Exception('Invalid Xml');
         }
     } else {
         throw new \InvalidArgumentException('File not found : ' . $source);
     }
     return $this;
 }