Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+63 -29
View File
@@ -3,19 +3,19 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Image Handler: GD2 Library
* Last Updated: $Date: 2010-10-25 11:38:36 -0400 (Mon, 25 Oct 2010) $
* Last Updated: $Date: 2011-08-12 05:44:20 -0400 (Fri, 12 Aug 2011) $
* </pre>
*
* @author $Author: mark $
* @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @link http://hatynka.in
* @since Monday 5th May 2008 14:00
* @version $Revision: 480 $
* @version $Revision: 9388 $
*
* GD Example
* <code>
@@ -44,10 +44,10 @@ class classImageGd extends classImage implements interfaceImage
/**
* Image resource
*
* @access private
* @access protected
* @var resource Image resource
*/
private $image = null;
protected $image = null;
/**
* Image quality settings
@@ -57,7 +57,7 @@ class classImageGd extends classImage implements interfaceImage
*/
public $quality = array( 'png' => 8, 'jpg' => 75 );
/**
/**
* Initiate image handler, perform any necessary setup
*
* @access public
@@ -70,17 +70,17 @@ class classImageGd extends classImage implements interfaceImage
// Verify input
//---------------------------------------------------------
if( !isset($opts['image_path']) OR !$opts['image_path'] )
if( empty($opts['image_path']) )
{
$this->error = 'no_image_path';
return false;
}
if( !isset($opts['image_file']) OR !$opts['image_file'] )
if( empty($opts['image_file']) )
{
$this->error = 'no_image_file';
return false;
}
}
//---------------------------------------------------------
// Store paths
@@ -110,12 +110,12 @@ class classImageGd extends classImage implements interfaceImage
// Quality values
//---------------------------------------------------------
if( isset($opts['jpg_quality']) AND $opts['jpg_quality'] )
if( !empty($opts['jpg_quality']) )
{
$this->quality['jpg'] = $opts['jpg_quality'];
}
if( isset($opts['png_quality']) AND $opts['png_quality'] )
if( !empty($opts['png_quality']) )
{
$this->quality['png'] = $opts['png_quality'];
}
@@ -147,8 +147,12 @@ class classImageGd extends classImage implements interfaceImage
case 'png':
$this->image = @imagecreatefrompng( $this->image_full );
imagealphablending( $this->image, TRUE );
imagesavealpha( $this->image, TRUE );
if( $this->image )
{
@imagealphablending( $this->image, TRUE );
@imagesavealpha( $this->image, TRUE );
}
break;
}
@@ -184,7 +188,14 @@ class classImageGd extends classImage implements interfaceImage
*/
public function croppedResize( $width, $height )
{
$ratioOrig = $this->orig_dimensions['width'] / $this->orig_dimensions['height'];
/* Changes here made to prevent "division by 0" errors when getimagesize() failed */
$ratioOrig = $this->orig_dimensions['width'] / ( $this->orig_dimensions['height'] ? $this->orig_dimensions['height'] : 1 );
/* This breaks square thumbs - always adds black bars */
if( $ratioOrig < 1 )
{
//$ratioOrig = 1;
}
if ( $width / $height > $ratioOrig )
{
@@ -212,6 +223,27 @@ class classImageGd extends classImage implements interfaceImage
return $this->resizeImage( $width, $height, true );
}
/**
* Crops an image
*
* @access public
* @param int Crop from X
* @param int Crop from Y
* @param int Width
* @param int Height
*
*/
public function crop( $x1, $y1, $width, $height )
{
$this->_cropX = $x1;
$this->_cropY = $y1;
$this->cur_dimensions['width'] = $width;
$this->cur_dimensions['height'] = $height;
return $this->resizeImage( $width, $height, true );
}
/**
* Resize image proportionately
*
@@ -219,9 +251,10 @@ class classImageGd extends classImage implements interfaceImage
* @param integer Maximum width
* @param integer Maximum height
* @param boolean Second pass of image for crop
* @param boolean Instead of resizing image to same size, return false if the image doesn't need to be resized
* @return array Dimensons of the original image and the resized dimensions
*/
public function resizeImage( $width, $height, $secondPass=false )
public function resizeImage( $width, $height, $secondPass=false, $returnIfUnnecessary=false )
{
//---------------------------------------------------------
// Get proportionate dimensions and store
@@ -244,7 +277,8 @@ class classImageGd extends classImage implements interfaceImage
return array( 'originalWidth' => $this->orig_dimensions['width'],
'originalHeight' => $this->orig_dimensions['height'],
'newWidth' => $this->orig_dimensions['width'],
'newHeight' => $this->orig_dimensions['height'] );
'newHeight' => $this->orig_dimensions['height'],
'noResize' => true );
}
else
{
@@ -398,15 +432,15 @@ class classImageGd extends classImage implements interfaceImage
* @param string File location (including file name)
* @return boolean File write successful
*/
public function writeImage( $path )
public function writeImage( $imagePath )
{
//---------------------------------------------------------
// Remove image if it exists
//---------------------------------------------------------
if( file_exists( $path ) )
if( is_file( $imagePath ) )
{
@unlink( $path );
@unlink( $imagePath );
}
//---------------------------------------------------------
@@ -416,23 +450,23 @@ class classImageGd extends classImage implements interfaceImage
switch( $this->image_extension )
{
case 'gif':
@imagegif( $this->image, $path );
@imagegif( $this->image, $imagePath );
break;
case 'jpeg':
case 'jpg':
case 'jpe':
@imagejpeg( $this->image, $path, $this->quality['jpg'] );
@imagejpeg( $this->image, $imagePath, $this->quality['jpg'] );
break;
case 'png':
@imagepng( $this->image, $path, $this->quality['png'] );
@imagepng( $this->image, $imagePath, $this->quality['png'] );
break;
}
if( !file_exists( $path ) )
if ( ! is_file( $imagePath ) )
{
$this->error = 'unable_to_write_image';
$this->error = 'unable_to_write_image';
return false;
}
@@ -440,7 +474,7 @@ class classImageGd extends classImage implements interfaceImage
// Chmod 777
//---------------------------------------------------------
@chmod( $path, 0777 );
@chmod( $imagePath, IPS_FILE_PERMISSION );
//---------------------------------------------------------
// Destroy image resource
@@ -455,7 +489,7 @@ class classImageGd extends classImage implements interfaceImage
* Print image to screen
*
* @access public
* @return void Image printed and script exits
* @return @e void Image printed and script exits
*/
public function displayImage()
{