CKFinder 3 – PHP Connector Documentation
All Classes Functions Variables Pages
Image Class Reference

Public Member Functions

 __construct ($imageData, $bmpSupport=false)
 
 hasValidGdImage ()
 
 setMemory ($imageWidth, $imageHeight, $imageBits, $imageChannels)
 
 createFromBmp ($data)
 
 resize ($maxWidth, $maxHeight, $quality=80, $useHigherFactor=false)
 
 getData ($format=null, $quality=80)
 
 getGDImage ()
 
 getDataSize ()
 
 getWidth ()
 
 getHeight ()
 
 getMimeType ()
 
 crop ($x, $y, $width, $height)
 
 rotate ($degrees, $bgcolor=0)
 
 getInfo ()
 

Static Public Member Functions

static create ($data, $bmpSupport=false)
 
static parseSize ($size)
 
static isSupportedExtension ($extension, $bmpSupport=false)
 
static mimeTypeFromExtension ($extension)
 
static calculateAspectRatio ($maxWidth, $maxHeight, $actualWidth, $actualHeight, $useHigherFactor=false)
 
 fastCopyResampled (&$dstImage, $srcImage, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH, $quality=3)
 

Protected Attributes

 $width
 
 $height
 
 $mime
 
 $bits
 
 $channels
 
 $gdImage
 
 $dataSize
 
 $resizeQuality
 

Static Protected Attributes

static $supportedExtensions = ['jpg', 'jpeg', 'gif', 'png']
 

Detailed Description

The Image class.

The class used for image processing.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $imageData,
  $bmpSupport = false 
)

Constructor.

Parameters
string$imageDataimage data
bool$bmpSupporttrue if bitmaps are supported (be aware of poor efficiency!)
Exceptions
CKFinderExceptionin case the image could not be initialized properly

Member Function Documentation

◆ calculateAspectRatio()

static calculateAspectRatio (   $maxWidth,
  $maxHeight,
  $actualWidth,
  $actualHeight,
  $useHigherFactor = false 
)
static

Returns the aspect ratio size as an associative array:.

array
(
     [width]  => 80
     [heigth] => 120
)
Parameters
int$maxWidthrequested width
int$maxHeightrequested height
int$actualWidthoriginal width
int$actualHeightoriginal height
bool$useHigherFactordefines which factor should be used to calculate the new size. For example:
  • original image size 800x400
  • calculateAspectRatio(300, 200, 800, 400, false) will return 300x150
  • calculateAspectRatio(300, 200, 800, 400, true) will return 400x200
Returns
array

◆ create()

static create (   $data,
  $bmpSupport = false 
)
static

The factory method.

Parameters
string$data
bool$bmpSupport
Returns
Image

◆ createFromBmp()

createFromBmp (   $data)

Source: http://pl.php.net/imagecreate (optimized for speed and memory usage, but yet not very efficient).

Parameters
string$databitmap data
Returns
resource

◆ fastCopyResampled()

fastCopyResampled ( $dstImage,
  $srcImage,
  $dstX,
  $dstY,
  $srcX,
  $srcY,
  $dstW,
  $dstH,
  $srcW,
  $srcH,
  $quality = 3 
)
static
See also
http://pl.php.net/manual/en/function.imagecopyresampled.php Replacement to imagecopyresampled that will deliver results that are almost identical except MUCH faster (very typically 30 times faster).
Parameters
resource$dstImage
resource$srcImage
int$dstX
int$dstY
int$srcX
int$srcY
int$dstW
int$dstH
int$srcW
int$srcH
int$quality
Returns
bool

◆ getData()

getData (   $format = null,
  $quality = 80 
)

Returns image data.

Parameters
string$formatreturned image format MIME type (current image MIME type is used if not set)
int$qualityImage quality (used for JPG images only)
Returns
string image data

◆ getDataSize()

getDataSize ( )

Returns the size of the image data produced by the getData() method.

Returns
int image data size in bytes

◆ getGDImage()

getGDImage ( )

Returns GD image resource.

Returns
resource GD image resource

◆ getHeight()

getHeight ( )

Returns image height in pixels.

Returns
int image height

◆ getMimeType()

getMimeType ( )

Returns image MIME type.

Returns
string MIME type

◆ getWidth()

getWidth ( )

Returns image width in pixels.

Returns
int image width

◆ hasValidGdImage()

hasValidGdImage ( )

Checks whether this object contains a valid GD image.

◆ isSupportedExtension()

static isSupportedExtension (   $extension,
  $bmpSupport = false 
)
static

Checks if a given exception is supported by the Image class.

Parameters
string$extension
bool$bmpSupport
Returns
bool

◆ mimeTypeFromExtension()

static mimeTypeFromExtension (   $extension)
static

Returns the MIME type for a given extension.

Parameters
string$extension
Returns
string MIME type

◆ parseSize()

static parseSize (   $size)
static

Parses the image size from a string in the form of [width]x[height], for example 278x219.

Parameters
string$sizeWxH string
Returns
array an array with width and height values array([width], [height]), for the example above: array(278, 219)

◆ resize()

resize (   $maxWidth,
  $maxHeight,
  $quality = 80,
  $useHigherFactor = false 
)

Resizes an image to a given size keeping the aspect ratio.

Parameters
int$maxWidthmaximum width
int$maxHeightmaximum height
int$qualityquality
bool$useHigherFactor
Returns
Image $this

◆ setMemory()

setMemory (   $imageWidth,
  $imageHeight,
  $imageBits,
  $imageChannels 
)
See also
http://pl.php.net/manual/pl/function.imagecreatefromjpeg.php function posted by e dot a dot schultz at gmail dot com
Parameters
mixed$imageWidth
mixed$imageHeight
mixed$imageBits
mixed$imageChannels
Returns
bool

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