[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/marc1706/fast-image-size/lib/Type/ -> TypeBmp.php (source)

   1  <?php
   2  
   3  /**
   4   * fast-image-size image type bmp
   5   * @package fast-image-size
   6   * @copyright (c) Marc Alexander <admin@m-a-styles.de>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace FastImageSize\Type;
  13  
  14  class TypeBmp extends TypeBase
  15  {
  16      /** @var int BMP header size needed for retrieving dimensions */
  17      const BMP_HEADER_SIZE = 26;
  18  
  19      /** @var string BMP signature */
  20      const BMP_SIGNATURE = "\x42\x4D";
  21  
  22      /** qvar int BMP dimensions offset */
  23      const BMP_DIMENSIONS_OFFSET = 18;
  24  
  25      /**
  26       * {@inheritdoc}
  27       */
  28  	public function getSize($filename)
  29      {
  30          $data = $this->fastImageSize->getImage($filename, 0, self::BMP_HEADER_SIZE);
  31  
  32          // Check if supplied file is a BMP file
  33          if (substr($data, 0, 2) !== self::BMP_SIGNATURE)
  34          {
  35              return;
  36          }
  37  
  38          $size = unpack('lwidth/lheight', substr($data, self::BMP_DIMENSIONS_OFFSET, 2 * self::LONG_SIZE));
  39  
  40          $this->fastImageSize->setSize($size);
  41          $this->fastImageSize->setImageType(IMAGETYPE_BMP);
  42      }
  43  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1