code: private function readPalette()
      {
          $length = self::getUInt2d($this->data, $this->pos + 2);
          $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
  
          // move stream pointer to next record
          $this->pos += 4 + $length;
  
          if (!$this->readDataOnly) {
              // offset: 0; size: 2; number of following colors
              $nm = self::getUInt2d($recordData, 0);
  
              // list of RGB colors
              for ($i = 0; $i < $nm; ++$i) {
                  $rgb = substr($recordData, 2 + 4 * $i, 4);
                  $this->palette[] = self::readRGB($rgb);
              }
          }
      }
docs: Read PALETTE record.