OPEN SOURCE SOCIAL NETWORK 6.6
Loading...
Searching...
No Matches
OssnImage Class Reference

Public Member Functions

 addFilter (callable $filter)
 
 __construct ($filename)
 
 imageCreateJpegfromExif ($filename)
 
 save ($filename, $image_type=null, $quality=null, $permissions=null, $exact_size=false)
 
 getImageAsString ($image_type=null, $quality=null)
 
 __toString ()
 
 output ($image_type=null, $quality=null)
 
 resizeToShortSide ($max_short, $allow_enlarge=false)
 
 resizeToLongSide ($max_long, $allow_enlarge=false)
 
 resizeToHeight ($height, $allow_enlarge=false)
 
 resizeToWidth ($width, $allow_enlarge=false)
 
 resizeToBestFit ($max_width, $max_height, $allow_enlarge=false)
 
 scale ($scale)
 
 resize ($width, $height, $allow_enlarge=false)
 
 crop ($width, $height, $allow_enlarge=false, $position=self::CROPCENTER)
 
 freecrop ($width, $height, $x=false, $y=false)
 
 getSourceWidth ()
 
 getSourceHeight ()
 
 getDestWidth ()
 
 getDestHeight ()
 
 imageFlip ($image, $mode)
 
 gamma ($enable=true)
 

Static Public Member Functions

static createFromString ($image_data)
 

Public Attributes

const CROPTOP = 1
 
const CROPCENTRE = 2
 
const CROPCENTER = 2
 
const CROPBOTTOM = 3
 
const CROPLEFT = 4
 
const CROPRIGHT = 5
 
const CROPTOPCENTER = 6
 
const IMG_FLIP_HORIZONTAL = 0
 
const IMG_FLIP_VERTICAL = 1
 
const IMG_FLIP_BOTH = 2
 
 $quality_jpg = 85
 
 $quality_webp = 85
 
 $quality_png = 6
 
 $quality_truecolor = true
 
 $gamma_correct = true
 
 $interlace = 1
 
 $source_type
 

Protected Member Functions

 applyFilter ($image, $filterType=IMG_FILTER_NEGATE)
 
 getCropPosition ($expectedSize, $position=self::CROPCENTER)
 

Protected Attributes

 $source_image
 
 $original_w
 
 $original_h
 
 $dest_x = 0
 
 $dest_y = 0
 
 $source_x
 
 $source_y
 
 $dest_w
 
 $dest_h
 
 $source_w
 
 $source_h
 
 $source_info
 
 $filters = array()
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $filename)

Loads image source and its properties to the instanciated object

Parameters
string$filename
Returns
ImageResize
Exceptions
Exception

Member Function Documentation

◆ __toString()

__toString ( )

Convert the image to string with the current settings

Returns
string

◆ addFilter()

addFilter ( callable  $filter)

Add filter function for use right before save image to file.

Parameters
callable$filter
Returns
$this

◆ applyFilter()

applyFilter (   $image,
  $filterType = IMG_FILTER_NEGATE 
)
protected

Apply filters.

Parameters
$imageresource an image resource identifier
$filterTypefilter type and default value is IMG_FILTER_NEGATE

◆ createFromString()

static createFromString (   $image_data)
static

Create instance from a strng

Parameters
string$image_data
Returns
ImageResize
Exceptions
Exception

◆ crop()

crop (   $width,
  $height,
  $allow_enlarge = false,
  $position = self::CROPCENTER 
)

Crops image according to the given width, height and crop position

Parameters
integer$width
integer$height
boolean$allow_enlarge
integer$position
Returns
static

◆ freecrop()

freecrop (   $width,
  $height,
  $x = false,
  $y = false 
)

Crops image according to the given width, height, x and y

Parameters
integer$width
integer$height
integer$x
integer$y
Returns
static

◆ gamma()

gamma (   $enable = true)

Enable or not the gamma color correction on the image, enabled by default

Parameters
bool$enable
Returns
static

◆ getCropPosition()

getCropPosition (   $expectedSize,
  $position = self::CROPCENTER 
)
protected

Gets crop position (X or Y) according to the given position

Parameters
integer$expectedSize
integer$position
Returns
float|integer

◆ getDestHeight()

getDestHeight ( )

Gets height of the destination image

Returns
integer

◆ getDestWidth()

getDestWidth ( )

Gets width of the destination image

Returns
integer

◆ getImageAsString()

getImageAsString (   $image_type = null,
  $quality = null 
)

Convert the image to string

Parameters
int$image_type
int$quality
Returns
string

◆ getSourceHeight()

getSourceHeight ( )

Gets source height

Returns
integer

◆ getSourceWidth()

getSourceWidth ( )

Gets source width

Returns
integer

◆ imageFlip()

imageFlip (   $image,
  $mode 
)

Flips an image using a given mode if PHP version is lower than 5.5

Parameters
resource$image
integer$mode
Returns
null

◆ output()

output (   $image_type = null,
  $quality = null 
)

Outputs image to browser

Parameters
string$image_type
integer$quality

◆ resize()

resize (   $width,
  $height,
  $allow_enlarge = false 
)

Resizes image according to the given width and height

Parameters
integer$width
integer$height
boolean$allow_enlarge
Returns
static

◆ resizeToBestFit()

resizeToBestFit (   $max_width,
  $max_height,
  $allow_enlarge = false 
)

Resizes image to best fit inside the given dimensions

Parameters
integer$max_width
integer$max_height
boolean$allow_enlarge
Returns
static

◆ resizeToHeight()

resizeToHeight (   $height,
  $allow_enlarge = false 
)

Resizes image according to the given height (width proportional)

Parameters
integer$height
boolean$allow_enlarge
Returns
static

◆ resizeToLongSide()

resizeToLongSide (   $max_long,
  $allow_enlarge = false 
)

Resizes image according to the given long side (short side proportional)

Parameters
integer$max_long
boolean$allow_enlarge
Returns
static

◆ resizeToShortSide()

resizeToShortSide (   $max_short,
  $allow_enlarge = false 
)

Resizes image according to the given short side (short side proportional)

Parameters
integer$max_short
boolean$allow_enlarge
Returns
static

◆ resizeToWidth()

resizeToWidth (   $width,
  $allow_enlarge = false 
)

Resizes image according to the given width (height proportional)

Parameters
integer$width
boolean$allow_enlarge
Returns
static

◆ save()

save (   $filename,
  $image_type = null,
  $quality = null,
  $permissions = null,
  $exact_size = false 
)

Saves new image

Parameters
string$filename
integer$image_type
integer$quality
integer$permissions
boolean$exact_size
Returns
static

◆ scale()

scale (   $scale)

Resizes image according to given scale (proportionally)

Parameters
integer | float$scale
Returns
static

The documentation for this class was generated from the following file: