|
@@ 648-651 (lines=4) @@
|
| 645 |
|
* @return bool|resource an image resource identifier on success, <b>FALSE</b> on errors. |
| 646 |
|
*/ |
| 647 |
|
private function imagecreatefrombmp($fileName) { |
| 648 |
|
if (!($fh = fopen($fileName, 'rb'))) { |
| 649 |
|
$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, array('app' => 'core')); |
| 650 |
|
return false; |
| 651 |
|
} |
| 652 |
|
// read file header |
| 653 |
|
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset', fread($fh, 14)); |
| 654 |
|
// check for bitmap |
|
@@ 655-659 (lines=5) @@
|
| 652 |
|
// read file header |
| 653 |
|
$meta = unpack('vtype/Vfilesize/Vreserved/Voffset', fread($fh, 14)); |
| 654 |
|
// check for bitmap |
| 655 |
|
if ($meta['type'] != 19778) { |
| 656 |
|
fclose($fh); |
| 657 |
|
$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', array('app' => 'core')); |
| 658 |
|
return false; |
| 659 |
|
} |
| 660 |
|
// read image header |
| 661 |
|
$meta += unpack('Vheadersize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vcolors/Vimportant', fread($fh, 40)); |
| 662 |
|
// read additional 16bit header |
|
@@ 679-683 (lines=5) @@
|
| 676 |
|
// in rare cases filesize is equal to offset so we need to read physical size |
| 677 |
|
if ($meta['imagesize'] < 1) { |
| 678 |
|
$meta['imagesize'] = @filesize($fileName) - $meta['offset']; |
| 679 |
|
if ($meta['imagesize'] < 1) { |
| 680 |
|
fclose($fh); |
| 681 |
|
$this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', array('app' => 'core')); |
| 682 |
|
return false; |
| 683 |
|
} |
| 684 |
|
} |
| 685 |
|
} |
| 686 |
|
// calculate colors |