[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * fast-image-size image type psd 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 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |