Nextcloud PHP API (stable18)

IImage

Class for basic image manipulation

Tags
since
8.1.0

Table of Contents

centerCrop()  : bool
Crops the image to the middle square. If the image is already square it just returns.
crop()  : bool
Crops the image from point $x$y with dimension $wx$h.
data()  : string
dataMimeType()  : string
fitIn()  : bool
Resizes the image to fit within a boundary while preserving ratio.
fixOrientation()  : bool
(I'm open for suggestions on better method name ;) Fixes orientation based on EXIF data.
getOrientation()  : int
(I'm open for suggestions on better method name ;) Get the orientation based on EXIF data.
height()  : int
Returns the height of the image or -1 if no image is loaded.
heightTopLeft()  : int
Returns the height when the image orientation is top-left.
mimeType()  : string
Returns the MIME type of the image or an empty string if no image is loaded.
preciseResize()  : bool
resize()  : bool
Resizes the image preserving ratio.
resource()  : resource
save()  : bool
Saves the image.
scaleDownToFit()  : bool
Shrinks the image to fit within a boundary while preserving ratio.
show()  : bool
Outputs the image.
valid()  : bool
Determine whether the object contains an image resource.
width()  : int
Returns the width of the image or -1 if no image is loaded.
widthTopLeft()  : int
Returns the width when the image orientation is top-left.

Methods

centerCrop()

Crops the image to the middle square. If the image is already square it just returns.

public centerCrop(int $size) : bool
Parameters
$size : int

maximum size for the result (optional)

Tags
since
8.1.0
Return values
bool

for success or failure

crop()

Crops the image from point $x$y with dimension $wx$h.

public crop(int $x, int $y, int $w, int $h) : bool
Parameters
$x : int

Horizontal position

$y : int

Vertical position

$w : int

Width

$h : int

Height

Tags
since
8.1.0
Return values
bool

for success or failure

data()

public data() : string
Tags
since
8.1.0
Return values
string

Returns the raw image data.

dataMimeType()

public dataMimeType() : string
Tags
since
13.0.0
Return values
string

Returns the raw data mimetype

fitIn()

Resizes the image to fit within a boundary while preserving ratio.

public fitIn(int $maxWidth, int $maxHeight) : bool
Parameters
$maxWidth : int
$maxHeight : int
Tags
since
8.1.0
Return values
bool

fixOrientation()

(I'm open for suggestions on better method name ;) Fixes orientation based on EXIF data.

public fixOrientation() : bool
Tags
since
8.1.0
Return values
bool

getOrientation()

(I'm open for suggestions on better method name ;) Get the orientation based on EXIF data.

public getOrientation() : int
Tags
since
8.1.0
Return values
int

The orientation or -1 if no EXIF data is available.

height()

Returns the height of the image or -1 if no image is loaded.

public height() : int
Tags
since
8.1.0
Return values
int

heightTopLeft()

Returns the height when the image orientation is top-left.

public heightTopLeft() : int
Tags
since
8.1.0
Return values
int

mimeType()

Returns the MIME type of the image or an empty string if no image is loaded.

public mimeType() : string
Tags
since
8.1.0
Return values
string

preciseResize()

public preciseResize(int $width, int $height) : bool
Parameters
$width : int
$height : int
Tags
since
8.1.0
Return values
bool

resize()

Resizes the image preserving ratio.

public resize(int $maxSize) : bool
Parameters
$maxSize : int

The maximum size of either the width or height.

Tags
since
8.1.0
Return values
bool

resource()

public resource() : resource
Tags
since
8.1.0
Return values
resource

Returns the image resource in any.

save()

Saves the image.

public save([string $filePath = null ][, string $mimeType = null ]) : bool
Parameters
$filePath : string = null
$mimeType : string = null
Tags
since
8.1.0
Return values
bool

scaleDownToFit()

Shrinks the image to fit within a boundary while preserving ratio.

public scaleDownToFit(int $maxWidth, int $maxHeight) : bool
Parameters
$maxWidth : int
$maxHeight : int
Tags
since
8.1.0
Return values
bool

show()

Outputs the image.

public show([string $mimeType = null ]) : bool
Parameters
$mimeType : string = null
Tags
since
8.1.0
Return values
bool

valid()

Determine whether the object contains an image resource.

public valid() : bool
Tags
since
8.1.0
Return values
bool

width()

Returns the width of the image or -1 if no image is loaded.

public width() : int
Tags
since
8.1.0
Return values
int

widthTopLeft()

Returns the width when the image orientation is top-left.

public widthTopLeft() : int
Tags
since
8.1.0
Return values
int

Search results