IImage

interface OCP\IImage
Class for basic image manipulation
Implemented by:OC_Image
Source:lib/public/IImage.php#33

Methods

public OCP\IImage::valid()
Determine whether the object contains an image resource.
Source:lib/public/IImage.php#40
Returns:bool
Since:8.1.0
public OCP\IImage::mimeType()
Returns the MIME type of the image or an empty string if no image is loaded.
Source:lib/public/IImage.php#48
Returns:string
Since:8.1.0
public OCP\IImage::width()
Returns the width of the image or -1 if no image is loaded.
Source:lib/public/IImage.php#56
Returns:int
Since:8.1.0
public OCP\IImage::height()
Returns the height of the image or -1 if no image is loaded.
Source:lib/public/IImage.php#64
Returns:int
Since:8.1.0
public OCP\IImage::widthTopLeft()
Returns the width when the image orientation is top-left.
Source:lib/public/IImage.php#72
Returns:int
Since:8.1.0
public OCP\IImage::heightTopLeft()
Returns the height when the image orientation is top-left.
Source:lib/public/IImage.php#80
Returns:int
Since:8.1.0
public OCP\IImage::show($mimeType=null)
Outputs the image.
Source:

lib/public/IImage.php#89

Parameters:
  • $mimeType (string)
Returns:

bool

Since:

8.1.0

public OCP\IImage::save($filePath=null, $mimeType=null)
Saves the image.
Source:

lib/public/IImage.php#99

Parameters:
  • $filePath (string)
  • $mimeType (string)
Returns:

bool

Since:

8.1.0

public OCP\IImage::resource()
Source:lib/public/IImage.php#105
Returns:resource Returns the image resource in any.
Since:8.1.0
public OCP\IImage::dataMimeType()
Source:lib/public/IImage.php#111
Returns:string Returns the raw data mimetype
Since:13.0.0
public OCP\IImage::data()
Source:lib/public/IImage.php#117
Returns:string Returns the raw image data.
Since:8.1.0
public OCP\IImage::getOrientation()
(I’m open for suggestions on better method name ;)
Get the orientation based on EXIF data.
Source:lib/public/IImage.php#126
Returns:int The orientation or -1 if no EXIF data is available.
Since:8.1.0
public OCP\IImage::fixOrientation()
(I’m open for suggestions on better method name ;)
Fixes orientation based on EXIF data.
Source:lib/public/IImage.php#135
Returns:bool
Since:8.1.0
public OCP\IImage::resize($maxSize)
Resizes the image preserving ratio.
Source:

lib/public/IImage.php#144

Parameters:
  • $maxSize (int) The maximum size of either the width or height.
Returns:

bool

Since:

8.1.0

public OCP\IImage::preciseResize($width, $height)
Source:

lib/public/IImage.php#152

Parameters:
  • $width (int)
  • $height (int)
Returns:

bool

Since:

8.1.0

public OCP\IImage::centerCrop($size=0)
Crops the image to the middle square. If the image is already square it just returns.
Source:

lib/public/IImage.php#161

Parameters:
  • $size (int) maximum size for the result (optional)
Returns:

bool for success or failure

Since:

8.1.0

public OCP\IImage::crop($x, $y, $w, $h)
Crops the image from point $x$y with dimension $wx$h.
Source:

lib/public/IImage.php#173

Parameters:
  • $x (int) Horizontal position
  • $y (int) Vertical position
  • $w (int) Width
  • $h (int) Height
Returns:

bool for success or failure

Since:

8.1.0

public OCP\IImage::fitIn($maxWidth, $maxHeight)
Resizes the image to fit within a boundary while preserving ratio.
Source:

lib/public/IImage.php#183

Parameters:
  • $maxWidth (int)
  • $maxHeight (int)
Returns:

bool

Since:

8.1.0

public OCP\IImage::scaleDownToFit($maxWidth, $maxHeight)
Shrinks the image to fit within a boundary while preserving ratio.
Source:

lib/public/IImage.php#193

Parameters:
  • $maxWidth (int)
  • $maxHeight (int)
Returns:

bool

Since:

8.1.0

public OCP\IImage::copy()
create a copy of this image
Source:lib/public/IImage.php#201
Returns:\OCP\IImage
Since:19.0.0
public OCP\IImage::cropCopy($x, $y, $w, $h)
create a new cropped copy of this image
Source:

lib/public/IImage.php#213

Parameters:
  • $x (int) Horizontal position
  • $y (int) Vertical position
  • $w (int) Width
  • $h (int) Height
Returns:

\OCP\IImage

Since:

19.0.0

public OCP\IImage::preciseResizeCopy($width, $height)
create a new resized copy of this image
Source:

lib/public/IImage.php#223

Parameters:
  • $width (int)
  • $height (int)
Returns:

\OCP\IImage

Since:

19.0.0

public OCP\IImage::resizeCopy($maxSize)
create a new resized copy of this image
Source:

lib/public/IImage.php#232

Parameters:
  • $maxSize (int) The maximum size of either the width or height.
Returns:

\OCP\IImage

Since:

19.0.0