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

TypeIff.php

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


 001  <?php
 002   
 003  /**
 004   * fast-image-size image type iff
 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 TypeIff extends TypeBase
 017  {
 018      /** @var int IFF header size. Grab more than what should be needed to make
 019       * sure we have the necessary data */
 020      const IFF_HEADER_SIZE = 32;
 021   
 022      /** @var string IFF header for Amiga type */
 023      const IFF_HEADER_AMIGA = 'FORM';
 024   
 025      /** @var string IFF header for Maya type */
 026      const IFF_HEADER_MAYA = 'FOR4';
 027   
 028      /** @var string IFF BTMHD for Amiga type */
 029      const IFF_AMIGA_BTMHD = 'BMHD';
 030   
 031      /** @var string IFF BTMHD for Maya type */
 032      const IFF_MAYA_BTMHD = 'BHD';
 033   
 034      /** @var string PHP pack format for unsigned short */
 035      const PACK_UNSIGNED_SHORT = 'n';
 036   
 037      /** @var string PHP pack format for unsigned long */
 038      const PACK_UNSIGNED_LONG = 'N';
 039   
 040      /** @var string BTMHD of current image */
 041      protected $btmhd;
 042   
 043      /** @var int Size of current BTMHD */
 044      protected $btmhdSize;
 045   
 046      /** @var string Current byte type */
 047      protected $byteType;
 048   
 049      /**
 050       * {@inheritdoc}
 051       */
 052      public function getSize(string $filename, ImageReader $imageReader): ?array
 053      {
 054          $data = $imageReader->getImage($filename, 0, self::IFF_HEADER_SIZE);
 055   
 056          if ($data === false)
 057          {
 058              return null;
 059          }
 060   
 061          $signature = $this->getIffSignature($data);
 062   
 063          // Check if image is IFF
 064          if ($signature === false)
 065          {
 066              return null;
 067          }
 068   
 069          // Set type constraints
 070          $this->setTypeConstraints($signature);
 071   
 072          // Get size from data
 073          $btmhdPosition = strpos($data, $this->btmhd);
 074          $size = unpack("{$this->byteType}width/{$this->byteType}height", substr($data, $btmhdPosition + self::LONG_SIZE + strlen($this->btmhd), $this->btmhdSize));
 075          $size['type'] = IMAGETYPE_IFF;
 076   
 077          return $size;
 078      }
 079   
 080      /**
 081       * Get IFF signature from data string
 082       *
 083       * @param string $data Image data string
 084       *
 085       * @return false|string Signature if file is a valid IFF file, false if not
 086       */
 087      protected function getIffSignature(string $data)
 088      {
 089          $signature = substr($data, 0, self::LONG_SIZE);
 090   
 091          // Check if image is IFF
 092          if ($signature !== self::IFF_HEADER_AMIGA && $signature !== self::IFF_HEADER_MAYA)
 093          {
 094              return false;
 095          }
 096          else
 097          {
 098              return $signature;
 099          }
 100      }
 101   
 102      /**
 103       * Set type constraints for current image
 104       *
 105       * @param string $signature IFF signature of image
 106       */
 107      protected function setTypeConstraints(string $signature): void
 108      {
 109          // Amiga version of IFF
 110          if ($signature === 'FORM')
 111          {
 112              $this->btmhd = self::IFF_AMIGA_BTMHD;
 113              $this->btmhdSize = self::LONG_SIZE;
 114              $this->byteType = self::PACK_UNSIGNED_SHORT;
 115          }
 116          // Maya version
 117          else
 118          {
 119              $this->btmhd = self::IFF_MAYA_BTMHD;
 120              $this->btmhdSize = self::LONG_SIZE * 2;
 121              $this->byteType = self::PACK_UNSIGNED_LONG;
 122          }
 123      }
 124  }
 125