Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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: 09.10.2024, 12:57 - Dateigröße: 3.55 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  class TypeTif extends TypeBase
 015  {
 016      /** @var int TIF header size. The header might be larger but the dimensions
 017       *            should be in the first 512 bytes */
 018      const TIF_HEADER_SIZE = 512;
 019   
 020      /** @var int TIF tag for image height */
 021      const TIF_TAG_IMAGE_HEIGHT = 257;
 022   
 023      /** @var int TIF tag for image width */
 024      const TIF_TAG_IMAGE_WIDTH = 256;
 025   
 026      /** @var int TIF tag type for short */
 027      const TIF_TAG_TYPE_SHORT = 3;
 028   
 029      /** @var int TIF IFD entry size */
 030      const TIF_IFD_ENTRY_SIZE = 12;
 031   
 032      /** @var string TIF signature of intel type */
 033      const TIF_SIGNATURE_INTEL = 'II';
 034   
 035      /** @var string TIF signature of motorola type */
 036      const TIF_SIGNATURE_MOTOROLA = 'MM';
 037   
 038      /** @var array Size info array */
 039      protected $size;
 040   
 041      /** @var string Bit type of long field */
 042      protected $typeLong;
 043   
 044      /** @var string Bit type of short field */
 045      protected $typeShort;
 046   
 047      /**
 048       * {@inheritdoc}
 049       */
 050      public function getSize($filename)
 051      {
 052          // Do not force length of header
 053          $data = $this->fastImageSize->getImage($filename, 0, self::TIF_HEADER_SIZE, false);
 054   
 055          $this->size = array();
 056   
 057          $signature = substr($data, 0, self::SHORT_SIZE);
 058   
 059          if (!in_array($signature, array(self::TIF_SIGNATURE_INTEL, self::TIF_SIGNATURE_MOTOROLA)))
 060          {
 061              return;
 062          }
 063   
 064          // Set byte type
 065          $this->setByteType($signature);
 066   
 067          // Get offset of IFD
 068          list(, $offset) = unpack($this->typeLong, substr($data, self::LONG_SIZE, self::LONG_SIZE));
 069   
 070          // Get size of IFD
 071          list(, $sizeIfd) = unpack($this->typeShort, substr($data, $offset, self::SHORT_SIZE));
 072   
 073          // Skip 2 bytes that define the IFD size
 074          $offset += self::SHORT_SIZE;
 075   
 076          // Filter through IFD
 077          for ($i = 0; $i < $sizeIfd; $i++)
 078          {
 079              // Get IFD tag
 080              $type = unpack($this->typeShort, substr($data, $offset, self::SHORT_SIZE));
 081   
 082              // Get field type of tag
 083              $fieldType = unpack($this->typeShort . 'type', substr($data, $offset + self::SHORT_SIZE, self::SHORT_SIZE));
 084   
 085              // Get IFD entry
 086              $ifdValue = substr($data, $offset + 2 * self::LONG_SIZE, self::LONG_SIZE);
 087   
 088              // Set size of field
 089              $this->setSizeInfo($type[1], $fieldType['type'], $ifdValue);
 090   
 091              $offset += self::TIF_IFD_ENTRY_SIZE;
 092          }
 093   
 094          $this->fastImageSize->setSize($this->size);
 095      }
 096   
 097      /**
 098       * Set byte type based on signature in header
 099       *
 100       * @param string $signature Header signature
 101       */
 102      protected function setByteType($signature)
 103      {
 104          if ($signature === self::TIF_SIGNATURE_INTEL)
 105          {
 106              $this->typeLong = 'V';
 107              $this->typeShort = 'v';
 108              $this->size['type'] = IMAGETYPE_TIFF_II;
 109          }
 110          else
 111          {
 112              $this->typeLong = 'N';
 113              $this->typeShort = 'n';
 114              $this->size['type'] = IMAGETYPE_TIFF_MM;
 115          }
 116      }
 117   
 118      /**
 119       * Set size info
 120       *
 121       * @param int $dimensionType Type of dimension. Either width or height
 122       * @param int $fieldLength Length of field. Either short or long
 123       * @param string $ifdValue String value of IFD field
 124       */
 125      protected function setSizeInfo($dimensionType, $fieldLength, $ifdValue)
 126      {
 127          // Set size of field
 128          $fieldSize = $fieldLength === self::TIF_TAG_TYPE_SHORT ? $this->typeShort : $this->typeLong;
 129   
 130          // Get actual dimensions from IFD
 131          if ($dimensionType === self::TIF_TAG_IMAGE_HEIGHT)
 132          {
 133              $this->size = array_merge($this->size, unpack($fieldSize . 'height', $ifdValue));
 134          }
 135          else if ($dimensionType === self::TIF_TAG_IMAGE_WIDTH)
 136          {
 137              $this->size = array_merge($this->size, unpack($fieldSize . 'width', $ifdValue));
 138          }
 139      }
 140  }
 141