\CodeIgniter\ImagesImageHandlerInterface

Expected behavior of an Image handler

Summary

Methods
Constants
resize()
crop()
convert()
rotate()
flatten()
reorient()
getEXIF()
flip()
fit()
text()
save()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

resize()

resize(integer  $width, integer  $height, boolean  $maintainRatio = false, string  $masterDim = 'auto') 

Resize the image

Parameters

integer $width
integer $height
boolean $maintainRatio

If true, will get the closest match possible while keeping aspect ratio true.

string $masterDim

crop()

crop(integer|null  $width = null, integer|null  $height = null, integer|null  $x = null, integer|null  $y = null, boolean  $maintainRatio = false, string  $masterDim = 'auto') : mixed

Crops the image to the desired height and width. If one of the height/width values is not provided, that value will be set the appropriate value based on offsets and image dimensions.

Parameters

integer|null $width
integer|null $height
integer|null $x

X-axis coord to start cropping from the left of image

integer|null $y

Y-axis coord to start cropping from the top of image

boolean $maintainRatio
string $masterDim

Returns

mixed

rotate()

rotate(float  $angle) : mixed

Rotates the image on the current canvas.

Parameters

float $angle

Returns

mixed

flatten()

flatten(integer  $red = 255, integer  $green = 255, integer  $blue = 255) : mixed

Flattens transparencies, default white background

Parameters

integer $red
integer $green
integer $blue

Returns

mixed

reorient()

reorient() : \CodeIgniter\Images\ImageHandlerInterface

Reads the EXIF information from the image and modifies the orientation so that displays correctly in the browser.

Returns

\CodeIgniter\Images\ImageHandlerInterface

getEXIF()

getEXIF(string|null  $key = null) : mixed

Retrieve the EXIF information from the image, if possible. Returns an array of the information, or null if nothing can be found.

Parameters

string|null $key

If specified, will only return this piece of EXIF data.

Returns

mixed

flip()

flip(string  $dir = 'vertical') : mixed

Flip an image horizontally or vertically

Parameters

string $dir

Direction to flip, either 'vertical' or 'horizontal'

Returns

mixed

fit()

fit(integer  $width, integer  $height, string  $position) : boolean

Combine cropping and resizing into a single command.

Supported positions:

  • top-left
  • top
  • top-right
  • left
  • center
  • right
  • bottom-left
  • bottom
  • bottom-right

Parameters

integer $width
integer $height
string $position

Returns

boolean

text()

text(string  $text, array  $options = array()) : $this

Overlays a string of text over the image.

Valid options:

  • color Text Color (hex number)
  • shadowColor Color of the shadow (hex number)
  • hAlign Horizontal alignment: left, center, right
  • vAlign Vertical alignment: top, middle, bottom
  • hOffset
  • vOffset
  • fontPath
  • fontSize
  • shadowOffset

Parameters

string $text
array $options

Returns

$this

save()

save(string  $target = null, integer  $quality = 90) : mixed

Saves any changes that have been made to file.

Example: $image->resize(100, 200, true) ->save($target);

Parameters

string $target
integer $quality

Returns

mixed