Nextcloud PHP API (master)

IImage

Class for basic image manipulation

Tags
since
8.1.0

Table of Contents

Methods

centerCrop()  : bool
Crops the image to the middle square. If the image is already square it just returns.
copy()  : IImage
create a copy of this image
crop()  : bool
Crops the image from point $x$y with dimension $wx$h.
cropCopy()  : IImage
create a new cropped copy of this image
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|null
Returns the MIME type of the image or null if no image is loaded.
preciseResize()  : bool
preciseResizeCopy()  : IImage
create a new resized copy of this image
resize()  : bool
Resizes the image preserving ratio.
resizeCopy()  : IImage
Resizes the image preserving ratio, returning a new copy
resource()  : false|resource|GdImage
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 = 0 ]) : bool
Parameters
$size : int = 0

maximum size for the result (optional)

Tags
since
8.1.0
Return values
bool

for success or failure

copy()

create a copy of this image

public copy() : IImage
Tags
since
19.0.0
Return values
IImage

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

cropCopy()

create a new cropped copy of this image

public cropCopy(int $x, int $y, int $w, int $h) : IImage
Parameters
$x : int

Horizontal position

$y : int

Vertical position

$w : int

Width

$h : int

Height

Tags
since
19.0.0
Return values
IImage

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 mimetype of the data. Returns null if the data is not valid.

fitIn()

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

public fitIn(int $maxWidth, int $maxHeight) : bool

Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up

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 null if no image is loaded.

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

preciseResize()

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

preciseResizeCopy()

create a new resized copy of this image

public preciseResizeCopy(int $width, int $height) : IImage
Parameters
$width : int
$height : int
Tags
since
19.0.0
Return values
IImage

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

resizeCopy()

Resizes the image preserving ratio, returning a new copy

public resizeCopy(int $maxSize) : IImage
Parameters
$maxSize : int

The maximum size of either the width or height.

Tags
since
19.0.0
Return values
IImage

resource()

public resource() : false|resource|GdImage
Tags
since
8.1.0
Return values
false|resource|GdImage

Returns the image resource if 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|null $mimeType = null ]) : bool
Parameters
$mimeType : string|null = 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

        
On this page

Search results