Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

TypeTif.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 3.88 KiB


001  <?php
002   
003  /**
004   * fast-image-size image type tif
005   * @package fast-image-size
006   * @copyright (c) Marc Alexander <admin@m-a-styles.de>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace FastImageSize\Type;
013   
014  use FastImageSize\ImageReader;
015   
016  class TypeTif extends TypeBase
017  {
018      /** @var int TIF header size. The header might be larger but the dimensions
019       *            should be in the first 256 kiB bytes */
020      const TIF_HEADER_SIZE = 262144;
021   
022      /** @var int TIF tag for image height */
023      const TIF_TAG_IMAGE_HEIGHT = 257;
024   
025      /** @var int TIF tag for image width */
026      const TIF_TAG_IMAGE_WIDTH = 256;
027   
028      /** @var int TIF tag type for short */
029      const TIF_TAG_TYPE_SHORT = 3;
030   
031      /** @var int TIF IFD entry size */
032      const TIF_IFD_ENTRY_SIZE = 12;
033   
034      /** @var string TIF signature of intel type */
035      const TIF_SIGNATURE_INTEL = 'II';
036   
037      /** @var string TIF signature of motorola type */
038      const TIF_SIGNATURE_MOTOROLA = 'MM';
039   
040      /** @var array Size info array */
041      protected $size;
042   
043      /** @var string Bit type of long field */
044      public $typeLong;
045   
046      /** @var string Bit type of short field */
047      public $typeShort;
048   
049      /**
050       * {@inheritdoc}
051       */
052      public function getSize(string $filename, ImageReader $imageReader): ?array
053      {
054          // Do not force length of header
055          $data = $imageReader->getImage($filename, 0, self::TIF_HEADER_SIZE, false);
056   
057          if ($data === false)
058          {
059              return null;
060          }
061   
062          $this->size = [];
063   
064          $signature = substr($data, 0, self::SHORT_SIZE);
065   
066          if ($signature !== self::TIF_SIGNATURE_INTEL && $signature !== self::TIF_SIGNATURE_MOTOROLA)
067          {
068              return null;
069          }
070   
071          // Set byte type
072          $this->setByteType($signature);
073   
074          // Get offset of IFD
075          list(, $offset) = unpack($this->typeLong, substr($data, self::LONG_SIZE, self::LONG_SIZE));
076   
077          // Get size of IFD
078          $ifdSizeInfo = substr($data, $offset, self::SHORT_SIZE);
079          if (empty($ifdSizeInfo))
080          {
081              return null;
082          }
083          list(, $sizeIfd) = unpack($this->typeShort, $ifdSizeInfo);
084   
085          // Skip 2 bytes that define the IFD size
086          $offset += self::SHORT_SIZE;
087   
088          // Ensure size can't exceed data length
089          $sizeIfd = min($sizeIfd, floor((strlen($data) - $offset) / self::TIF_IFD_ENTRY_SIZE));
090   
091          // Filter through IFD
092          for ($i = 0; $i < $sizeIfd; $i++)
093          {
094              // Get IFD tag
095              $type = unpack($this->typeShort, substr($data, $offset, self::SHORT_SIZE));
096   
097              // Get field type of tag
098              $fieldType = unpack($this->typeShort . 'type', substr($data, $offset + self::SHORT_SIZE, self::SHORT_SIZE));
099   
100              // Get IFD entry
101              $ifdValue = substr($data, $offset + 2 * self::LONG_SIZE, self::LONG_SIZE);
102   
103              // Set size of field
104              $this->setSizeInfo($type[1], $fieldType['type'], $ifdValue);
105   
106              $offset += self::TIF_IFD_ENTRY_SIZE;
107          }
108   
109          return $this->size;
110      }
111   
112      /**
113       * Set byte type based on signature in header
114       *
115       * @param string $signature Header signature
116       */
117      public function setByteType(string $signature): void
118      {
119          if ($signature === self::TIF_SIGNATURE_INTEL)
120          {
121              $this->typeLong = 'V';
122              $this->typeShort = 'v';
123              $this->size['type'] = IMAGETYPE_TIFF_II;
124          }
125          else
126          {
127              $this->typeLong = 'N';
128              $this->typeShort = 'n';
129              $this->size['type'] = IMAGETYPE_TIFF_MM;
130          }
131      }
132   
133      /**
134       * Set size info
135       *
136       * @param int $dimensionType Type of dimension. Either width or height
137       * @param int $fieldLength Length of field. Either short or long
138       * @param string $ifdValue String value of IFD field
139       */
140      protected function setSizeInfo(int $dimensionType, int $fieldLength, string $ifdValue): void
141      {
142          // Set size of field
143          $fieldSize = $fieldLength === self::TIF_TAG_TYPE_SHORT ? $this->typeShort : $this->typeLong;
144   
145          // Get actual dimensions from IFD
146          if ($dimensionType === self::TIF_TAG_IMAGE_HEIGHT)
147          {
148              $this->size = array_merge($this->size, unpack($fieldSize . 'height', $ifdValue));
149          }
150          else if ($dimensionType === self::TIF_TAG_IMAGE_WIDTH)
151          {
152              $this->size = array_merge($this->size, unpack($fieldSize . 'width', $ifdValue));
153          }
154      }
155  }
156