PHP Class Eventviva\ImageResize

Show file Open project: eventviva/php-image-resize Class Usage Examples

Public Properties

Property Type Description
$interlace
$quality_jpg
$quality_png
$source_type

Protected Properties

Property Type Description
$dest_h
$dest_w
$dest_x
$dest_y
$original_h
$original_w
$source_h
$source_image
$source_w
$source_x
$source_y

Public Methods

Method Description
__construct ( string $filename ) : ImageResize Loads image source and its properties to the instanciated object
__toString ( ) : string Convert the image to string with the current settings
createFromString ( string $image_data ) : ImageResize Create instance from a strng
crop ( integer $width, integer $height, boolean $allow_enlarge = false, integer $position = self::CROPCENTER ) : static Crops image according to the given width, height and crop position
freecrop ( integer $width, integer $height, integer $x = false, integer $y = false ) : static Crops image according to the given width, height, x and y
getDestHeight ( ) : integer Gets height of the destination image
getDestWidth ( ) : integer Gets width of the destination image
getImageAsString ( integer $image_type = null, integer $quality = null ) : string Convert the image to string
getSourceHeight ( ) : integer Gets source height
getSourceWidth ( ) : integer Gets source width
imageCreateJpegfromExif ( $filename ) http://stackoverflow.com/a/28819866
output ( string $image_type = null, integer $quality = null ) Outputs image to browser
resize ( integer $width, integer $height, boolean $allow_enlarge = false ) : static Resizes image according to the given width and height
resizeToBestFit ( integer $max_width, integer $max_height, boolean $allow_enlarge = false ) : static Resizes image to best fit inside the given dimensions
resizeToHeight ( integer $height, boolean $allow_enlarge = false ) : static Resizes image according to the given height (width proportional)
resizeToWidth ( integer $width, boolean $allow_enlarge = false ) : static Resizes image according to the given width (height proportional)
save ( string $filename, string $image_type = null, integer $quality = null, integer $permissions = null ) : static Saves new image
scale ( integer | float $scale ) : static Resizes image according to given scale (proportionally)

Protected Methods

Method Description
getCropPosition ( integer $expectedSize, integer $position = self::CROPCENTER ) : integer Gets crop position (X or Y) according to the given position

Method Details

__construct() public method

Loads image source and its properties to the instanciated object
public __construct ( string $filename ) : ImageResize
$filename string
return ImageResize

__toString() public method

Convert the image to string with the current settings
public __toString ( ) : string
return string

createFromString() public static method

Create instance from a strng
public static createFromString ( string $image_data ) : ImageResize
$image_data string
return ImageResize

crop() public method

Crops image according to the given width, height and crop position
public crop ( integer $width, integer $height, boolean $allow_enlarge = false, integer $position = self::CROPCENTER ) : static
$width integer
$height integer
$allow_enlarge boolean
$position integer
return static

freecrop() public method

Crops image according to the given width, height, x and y
public freecrop ( integer $width, integer $height, integer $x = false, integer $y = false ) : static
$width integer
$height integer
$x integer
$y integer
return static

getCropPosition() protected method

Gets crop position (X or Y) according to the given position
protected getCropPosition ( integer $expectedSize, integer $position = self::CROPCENTER ) : integer
$expectedSize integer
$position integer
return integer

getDestHeight() public method

Gets height of the destination image
public getDestHeight ( ) : integer
return integer

getDestWidth() public method

Gets width of the destination image
public getDestWidth ( ) : integer
return integer

getImageAsString() public method

Convert the image to string
public getImageAsString ( integer $image_type = null, integer $quality = null ) : string
$image_type integer
$quality integer
return string

getSourceHeight() public method

Gets source height
public getSourceHeight ( ) : integer
return integer

getSourceWidth() public method

Gets source width
public getSourceWidth ( ) : integer
return integer

imageCreateJpegfromExif() public method

http://stackoverflow.com/a/28819866
public imageCreateJpegfromExif ( $filename )

output() public method

Outputs image to browser
public output ( string $image_type = null, integer $quality = null )
$image_type string
$quality integer

resize() public method

Resizes image according to the given width and height
public resize ( integer $width, integer $height, boolean $allow_enlarge = false ) : static
$width integer
$height integer
$allow_enlarge boolean
return static

resizeToBestFit() public method

Resizes image to best fit inside the given dimensions
public resizeToBestFit ( integer $max_width, integer $max_height, boolean $allow_enlarge = false ) : static
$max_width integer
$max_height integer
$allow_enlarge boolean
return static

resizeToHeight() public method

Resizes image according to the given height (width proportional)
public resizeToHeight ( integer $height, boolean $allow_enlarge = false ) : static
$height integer
$allow_enlarge boolean
return static

resizeToWidth() public method

Resizes image according to the given width (height proportional)
public resizeToWidth ( integer $width, boolean $allow_enlarge = false ) : static
$width integer
$allow_enlarge boolean
return static

save() public method

Saves new image
public save ( string $filename, string $image_type = null, integer $quality = null, integer $permissions = null ) : static
$filename string
$image_type string
$quality integer
$permissions integer
return static

scale() public method

Resizes image according to given scale (proportionally)
public scale ( integer | float $scale ) : static
$scale integer | float
return static

Property Details

$dest_h protected property

protected $dest_h

$dest_w protected property

protected $dest_w

$dest_x protected property

protected $dest_x

$dest_y protected property

protected $dest_y

$interlace public property

public $interlace

$original_h protected property

protected $original_h

$original_w protected property

protected $original_w

$quality_jpg public property

public $quality_jpg

$quality_png public property

public $quality_png

$source_h protected property

protected $source_h

$source_image protected property

protected $source_image

$source_type public property

public $source_type

$source_w protected property

protected $source_w

$source_x protected property

protected $source_x

$source_y protected property

protected $source_y