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

TypePsd.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 1.50 KiB


 01  <?php
 02   
 03  /**
 04   * fast-image-size image type psd
 05   * @package fast-image-size
 06   * @copyright (c) Marc Alexander <admin@m-a-styles.de>
 07   *
 08   * For the full copyright and license information, please view the LICENSE
 09   * file that was distributed with this source code.
 10   */
 11   
 12  namespace FastImageSize\Type;
 13   
 14  class TypePsd extends TypeBase
 15  {
 16      /** @var string PSD signature */
 17      const PSD_SIGNATURE = "8BPS";
 18   
 19      /** @var int PSD header size */
 20      const PSD_HEADER_SIZE = 22;
 21   
 22      /** @var int PSD dimensions info offset */
 23      const PSD_DIMENSIONS_OFFSET = 14;
 24   
 25      /**
 26       * {@inheritdoc}
 27       */
 28      public function getSize($filename)
 29      {
 30          $data = $this->fastImageSize->getImage($filename, 0, self::PSD_HEADER_SIZE);
 31   
 32          if ($data === false)
 33          {
 34              return;
 35          }
 36   
 37          // Offset for version info is length of header but version is only a
 38          // 16-bit unsigned value
 39          $version = unpack('n', substr($data, self::LONG_SIZE, 2));
 40   
 41          // Check if supplied file is a PSD file
 42          if (!$this->validPsd($data, $version))
 43          {
 44              return;
 45          }
 46   
 47          $size = unpack('Nheight/Nwidth', substr($data, self::PSD_DIMENSIONS_OFFSET, 2 * self::LONG_SIZE));
 48   
 49          $this->fastImageSize->setSize($size);
 50          $this->fastImageSize->setImageType(IMAGETYPE_PSD);
 51      }
 52   
 53      /**
 54       * Return whether file is a valid PSD file
 55       *
 56       * @param string $data Image data string
 57       * @param array $version Version array
 58       *
 59       * @return bool True if image is a valid PSD file, false if not
 60       */
 61      protected function validPsd($data, $version)
 62      {
 63          return substr($data, 0, self::LONG_SIZE) === self::PSD_SIGNATURE && $version[1] === 1;
 64      }
 65  }
 66