OC_Image¶
-
class
OC_Image
¶ - Class for basic image manipulation
Source: lib/private/legacy/OC_Image.php#48 Implements: OCP\IImage
Properties¶
-
protected static property
OC_Image::$
resource
¶ Source: lib/private/legacy/OC_Image.php#50 Type: bool | resource
-
protected static property
OC_Image::$
imageType
¶ Source: lib/private/legacy/OC_Image.php#52 Type: int
-
protected static property
OC_Image::$
mimeType
¶ Source: lib/private/legacy/OC_Image.php#54 Type: string
-
protected static property
OC_Image::$
bitDepth
¶ Source: lib/private/legacy/OC_Image.php#56 Type: int
-
protected static property
OC_Image::$
filePath
¶ Source: lib/private/legacy/OC_Image.php#58 Type: null | string
Methods¶
-
public
OC_Image::
__construct
($imageRef=\null, $logger=\null, $config=\null)¶ - Constructor.
Source: Parameters: - $imageRef (resource | string) The path to a local file, a base64 encoded string or a resource created by
an imagecreate* function. * $logger (
OCP\ILogger
) * $config (OCP\IConfig
)Throws: \InvalidArgumentException
in case the $imageRef parameter is not null
-
public
OC_Image::
valid
()¶ - Determine whether the object contains an image resource.
Source: lib/private/legacy/OC_Image.php#101 Returns: bool
-
public
OC_Image::
mimeType
()¶ - Returns the MIME type of the image or an empty string if no image is loaded.
Source: lib/private/legacy/OC_Image.php#117 Returns: string
-
public
OC_Image::
width
()¶ - Returns the width of the image or -1 if no image is loaded.
Source: lib/private/legacy/OC_Image.php#126 Returns: int
-
public
OC_Image::
height
()¶ - Returns the height of the image or -1 if no image is loaded.
Source: lib/private/legacy/OC_Image.php#135 Returns: int
-
public
OC_Image::
widthTopLeft
()¶ - Returns the width when the image orientation is top-left.
Source: lib/private/legacy/OC_Image.php#144 Returns: int
-
public
OC_Image::
heightTopLeft
()¶ - Returns the height when the image orientation is top-left.
Source: lib/private/legacy/OC_Image.php#168 Returns: int
-
public
OC_Image::
show
($mimeType=\null)¶ - Outputs the image.
Source: Parameters: - $mimeType (string)
Returns: bool
-
public
OC_Image::
save
($filePath=\null, $mimeType=\null)¶ - Saves the image.
Source: Parameters: - $filePath (string)
- $mimeType (string)
Returns: bool
-
public
OC_Image::
__invoke
()¶ - Prints the image when called as $image().
Source: lib/private/legacy/OC_Image.php#307
-
public
OC_Image::
setResource
($resource)¶ Source: lib/private/legacy/OC_Image.php#315 Parameters: Throws: \InvalidArgumentException
in case the supplied resource does not have the type “gd”
-
public
OC_Image::
resource
()¶ Source: lib/private/legacy/OC_Image.php#332 Returns: resource Returns the image resource in any.
-
public
OC_Image::
dataMimeType
()¶ Source: lib/private/legacy/OC_Image.php#340 Returns: string Returns the mimetype of the data. Returns the empty string if the data is not valid.
-
public
OC_Image::
data
()¶ Source: lib/private/legacy/OC_Image.php#358 Returns: null | string Returns the raw image data.
-
public
OC_Image::
__toString
()¶ Source: lib/private/legacy/OC_Image.php#392 Returns: string - base64 encoded, which is suitable for embedding in a VCard.
-
protected
OC_Image::
getJpegQuality
()¶ Source: lib/private/legacy/OC_Image.php#399 Returns: int | null
-
public
OC_Image::
getOrientation
()¶ - (I’m open for suggestions on better method name ;)Get the orientation based on EXIF data.
Source: lib/private/legacy/OC_Image.php#413 Returns: int The orientation or -1 if no EXIF data is available.
-
public
OC_Image::
readExif
($data)¶ Source: lib/private/legacy/OC_Image.php#445
-
public
OC_Image::
fixOrientation
()¶ - (I’m open for suggestions on better method name ;)Fixes orientation based on EXIF data.
Source: lib/private/legacy/OC_Image.php#471 Returns: bool
-
public
OC_Image::
loadFromFileHandle
($handle)¶ - Loads an image from an open file handle.It is the responsibility of the caller to position the pointer at the correct place and to close the handle again.
Source: Parameters: - $handle (resource)
Returns: resource | bool An image resource or false on error
-
public
OC_Image::
loadFromFile
($imagePath=\false)¶ - Loads an image from a local file.
Source: Parameters: - $imagePath (bool | string) The path to a local file.
Returns: bool | resource An image resource or false on error
-
public
OC_Image::
loadFromData
($str)¶ - Loads an image from a string of data.
Source: Parameters: - $str (string) A string of image data as read from a file.
Returns: bool | resource An image resource or false on error
-
public
OC_Image::
loadFromBase64
($str)¶ - Loads an image from a base64 encoded string.
Source: Parameters: - $str (string) A string base64 encoded string of image data.
Returns: bool | resource An image resource or false on error
-
public
OC_Image::
resize
($maxSize)¶ - Resizes the image preserving ratio.
Source: Parameters: - $maxSize (int) The maximum size of either the width or height.
Returns: bool
-
public
OC_Image::
preciseResize
($width, $height)¶ Source: Parameters: - $width (int)
- $height (int)
Returns: bool
-
public
OC_Image::
preciseResizeNew
($width, $height)¶ Source: Parameters: - $width (int)
- $height (int)
Returns: resource | bool
-
public
OC_Image::
centerCrop
($size=0)¶ - Crops the image to the middle square. If the image is already square it just returns.
Source: Parameters: - $size (int) maximum size for the result (optional)
Returns: bool for success or failure
-
public
OC_Image::
crop
($x, $y, $w, $h)¶ - Crops the image from point $x$y with dimension $wx$h.
Source: Parameters: - $x (int) Horizontal position
- $y (int) Vertical position
- $w (int) Width
- $h (int) Height
Returns: bool for success or failure
-
public
OC_Image::
cropNew
($x, $y, $w, $h)¶ - Crops the image from point $x$y with dimension $wx$h.
Source: Parameters: - $x (int) Horizontal position
- $y (int) Vertical position
- $w (int) Width
- $h (int) Height
Returns: resource | bool
-
public
OC_Image::
fitIn
($maxWidth, $maxHeight)¶ - Resizes the image to fit within a boundary while preserving ratio.Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up
Source: Parameters: - $maxWidth (int)
- $maxHeight (int)
Returns: bool
-
public
OC_Image::
scaleDownToFit
($maxWidth, $maxHeight)¶ - Shrinks larger images to fit within specified boundaries while preserving ratio.
Source: Parameters: - $maxWidth (int)
- $maxHeight (int)
Returns: bool
-
public
OC_Image::
copy
()¶ Source: lib/private/legacy/OC_Image.php#1106
-
public
OC_Image::
cropCopy
($x, $y, $w, $h)¶ Source: lib/private/legacy/OC_Image.php#1123
-
public
OC_Image::
preciseResizeCopy
($width, $height)¶ Source: lib/private/legacy/OC_Image.php#1133
-
public
OC_Image::
resizeCopy
($maxSize)¶ Source: lib/private/legacy/OC_Image.php#1143
-
public
OC_Image::
copyResize
($maxSize)¶ - Resizes the image preserving ratio, returning a new copy
Source: Parameters: - $maxSize (int) The maximum size of either the width or height.
Returns: bool
-
public
OC_Image::
destroy
()¶ - Destroys the current image and resets the object
Source: lib/private/legacy/OC_Image.php#1166
-
public
OC_Image::
__destruct
()¶ Source: lib/private/legacy/OC_Image.php#1173