Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
+44
-25
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Image Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 19 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -52,6 +52,39 @@ abstract class _Image
|
||||
*/
|
||||
public static function create( $contents )
|
||||
{
|
||||
/* Work out the type */
|
||||
$imageType = NULL;
|
||||
$isAnimated = FALSE;
|
||||
$signatures = array(
|
||||
'gif' => array(
|
||||
'47' . '49' . '46' . '38' . '37' . '61',
|
||||
'47' . '49' . '46' . '38' . '39' . '61'
|
||||
),
|
||||
'jpeg' => array(
|
||||
'ff' . 'd8' . 'ff'
|
||||
),
|
||||
'png' => array(
|
||||
'89' . '50' . '4e' . '47' . '0d' . '0a' . '1a' . '0a'
|
||||
)
|
||||
);
|
||||
$bytesNeeded = max( array_map( 'strlen', array_map( 'hex2bin', call_user_func_array( 'array_merge', $signatures ) ) ) );
|
||||
$fileHeader = \substr( $contents, 0, $bytesNeeded );
|
||||
foreach ( $signatures as $type => $_signatures )
|
||||
{
|
||||
foreach ( $_signatures as $signature )
|
||||
{
|
||||
if ( bin2hex( \substr( $fileHeader, 0, \strlen( hex2bin( $signature ) ) ) ) === $signature )
|
||||
{
|
||||
$imageType = $type;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $imageType === NULL )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
|
||||
/* Create object */
|
||||
if( \IPS\Settings::i()->image_suite == 'imagemagick' and class_exists( 'Imagick', FALSE ) )
|
||||
{
|
||||
@@ -61,29 +94,15 @@ abstract class _Image
|
||||
{
|
||||
$obj = new Image\Gd( $contents );
|
||||
}
|
||||
|
||||
/* Work out the type */
|
||||
preg_match( '/\A(?:(\xff\xd8\xff)|(GIF8[79]a)|(\x89PNG\x0d\x0a)|(BM)|(\x49\x49(?:\x2a\x00|\x00\x4a))|(FORM.{4}ILBM))/', $contents, $matches );
|
||||
switch ( count( $matches ) )
|
||||
$obj->type = $imageType;
|
||||
|
||||
/* Animated? */
|
||||
if ( $obj->type === 'gif' and (boolean) preg_match( '#(\x00\x21\xF9\x04.{4}\x00\x2C.*){2,}#s', $contents ) )
|
||||
{
|
||||
case 2:
|
||||
$obj->type = 'jpeg';
|
||||
break;
|
||||
case 3:
|
||||
$obj->type = 'gif';
|
||||
if ( (boolean) preg_match( '#(\x00\x21\xF9\x04.{4}\x00\x2C.*){2,}#s', $contents ) )
|
||||
{
|
||||
$obj->isAnimatedGif = TRUE;
|
||||
$obj->contents = $contents;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
$obj->type = 'png';
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException;
|
||||
$obj->isAnimatedGif = TRUE;
|
||||
$obj->contents = $contents;
|
||||
}
|
||||
|
||||
|
||||
/* Set EXIF data immediately */
|
||||
if( static::exifSupported() )
|
||||
{
|
||||
@@ -149,7 +168,7 @@ abstract class _Image
|
||||
/**
|
||||
* @brief Type ('png', 'jpeg' or 'gif')
|
||||
*/
|
||||
protected $type;
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @brief Width
|
||||
@@ -164,7 +183,7 @@ abstract class _Image
|
||||
/**
|
||||
* @brief Is this an animated gif?
|
||||
*/
|
||||
protected $isAnimatedGif = FALSE;
|
||||
public $isAnimatedGif = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Contents of the image file when animated gif
|
||||
|
||||
Reference in new issue
Block a user