Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+11 -4
View File
@@ -2,9 +2,9 @@
/**
* @brief Image Class - GD
* @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
*/
@@ -21,7 +21,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
/**
* Image Class - GD
*/
class _GD extends \IPS\Image
class _Gd extends \IPS\Image
{
/**
* @brief Image Resource
@@ -41,6 +41,11 @@ class _GD extends \IPS\Image
$this->image = @imagecreatefromstring( $contents );
if ( $this->image === FALSE )
{
if ( $error = error_get_last() )
{
throw new \InvalidArgumentException( $error['message'], $error['type'] );
}
throw new \InvalidArgumentException;
}
@@ -85,7 +90,7 @@ class _GD extends \IPS\Image
break;
case 'jpeg':
$quality = \IPS\Settings::i()->image_jpg_quality ?: 75;
$quality = \IPS\Settings::i()->image_jpg_quality ?: 85;
imagejpeg( $this->image, NULL, $quality );
break;
@@ -139,6 +144,8 @@ class _GD extends \IPS\Image
}
/* Create a new canvas */
$width = ceil( $width );
$height = ceil( $height );
$newImage = imagecreatetruecolor( $width, $height );
switch( $this->type )
{
+44 -25
View File
@@ -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
+25 -9
View File
@@ -2,9 +2,9 @@
/**
* @brief Image Class - ImageMagick
* @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 06 Mar 2014
* @version SVN_VERSION_NUMBER
*/
@@ -51,7 +51,13 @@ class _Imagemagick extends \IPS\Image
}
catch ( \ImagickException $e )
{
throw new \InvalidArgumentException;
throw new \InvalidArgumentException( $e->getMessage(), $e->getCode() );
}
/* Set quality (if image format is JPEG) */
if ( in_array( $this->imagick->getImageFormat(), array( 'jpg', 'jpeg' ) ) )
{
$this->imagick->setImageCompressionQuality( (int) \IPS\Settings::i()->image_jpg_quality ?: 85 );
}
/* Set width/height */
@@ -135,7 +141,22 @@ class _Imagemagick extends \IPS\Image
*/
public function cropToPoints( $point1X, $point1Y, $point2X, $point2Y )
{
$this->imagick->cropImage( $point2X - $point1X, $point2Y - $point1Y, $point1X, $point1Y );
if( mb_strtolower( $this->imagick->getImageFormat() ) === 'gif' )
{
$this->imagick = $this->imagick->coalesceImages();
foreach( $this->imagick as $frame )
{
$frame->cropImage( $point2X - $point1X, $point2Y - $point1Y, $point1X, $point1Y );
$frame->setImagePage($point2X - $point1X, $point2Y - $point1Y, 0, 0);
}
$this->imagick = $this->imagick->deconstructImages();
}
else
{
$this->imagick->cropImage( $point2X - $point1X, $point2Y - $point1Y, $point1X, $point1Y );
}
/* Set width/height */
$this->setDimensions();
@@ -180,11 +201,6 @@ class _Imagemagick extends \IPS\Image
$this->height = $this->imagick->getImageHeight();
}
/**
* Get Image Orientation
*
* @return int|NULL
*/
/**
* Get Image Orientation
*