コード例 #1
0
ファイル: ExifParser.php プロジェクト: boedy/FasterImage
 /**
  * @return bool
  * @throws \FasterImage\Exception\InvalidImageException
  */
 protected function parseExifIfd()
 {
     $byte_order = $this->stream->read(2);
     switch ($byte_order) {
         case 'II':
             $this->short = 'v';
             $this->long = 'V';
             break;
         case 'MM':
             $this->short = 'n';
             $this->long = 'N';
             break;
         default:
             throw new InvalidImageException();
             break;
     }
     $this->stream->read(2);
     $offset = current(unpack($this->long, $this->stream->read(4)));
     $this->stream->read($offset - 8);
     $tag_count = current(unpack($this->short, $this->stream->read(2)));
     for ($i = $tag_count; $i > 0; $i--) {
         $type = current(unpack($this->short, $this->stream->read(2)));
         $this->stream->read(6);
         $data = current(unpack($this->short, $this->stream->read(2)));
         switch ($type) {
             case 0x100:
                 $this->width = $data;
                 break;
             case 0x101:
                 $this->height = $data;
                 break;
             case 0x112:
                 $this->orientation = $data;
                 break;
         }
         if (isset($this->width) && isset($this->height) && isset($this->orientation)) {
             return true;
         }
         $this->stream->read(2);
     }
     return false;
 }
コード例 #2
0
ファイル: ImageParser.php プロジェクト: boedy/FasterImage
 /**
  * @return mixed
  */
 private function getByte()
 {
     return $this->readByte($this->stream->read(1));
 }