Documentation

Utils
in package

Image utility functions.

Tags
author

Jose Quintana https://joseluisq.net

Table of Contents

$imageTypes  : array<string|int, mixed>
$mimeTypes  : array<string|int, mixed>
$imageTypes  : mixed
$mimeTypes  : mixed
fixPNGOpacity()  : int
Fix the opacity value (0 to 1) for PNG alpha value.
getExtension()  : string
Gets image extension from filename.
getImageType()  : bool
Gets image type from filename.
getMimetype()  : string
Gets image mimeType by filename.
getMimetypeByImageType()  : string
Gets image mime type by image type (IMAGETYPE_GIF, IMAGETYPE_PNG or IMAGETYPE_JPEG).
getMimetypes()  : array<string|int, mixed>
Gets image mime types (jpg, png and gif).
isGIF()  : bool
Checks if image path is a PNG.
isJPG()  : bool
Checks if image path is a JPG.
isJPGResource()  : bool
Checks if image resource is a JPG.
isPNG()  : bool
Checks if image path is a PNG.
isPNGResource()  : bool
Checks if image resource is a PNG.

Properties

$imageTypes

public array<string|int, mixed> $imageTypes

Types: IMAGETYPE_GIF, IMAGETYPE_PNG and IMAGETYPE_JPEG.

$mimeTypes

public array<string|int, mixed> $mimeTypes

Mime types for images.

$imageTypes

private static mixed $imageTypes = ['gif' => IMAGETYPE_GIF, 'png' => IMAGETYPE_PNG, 'jpg' => IMAGETYPE_JPEG]
Tags

$mimeTypes

private static mixed $mimeTypes = [IMAGETYPE_GIF => 'image/gif', IMAGETYPE_PNG => 'image/png', IMAGETYPE_JPEG => 'image/jpeg']
Tags

Methods

fixPNGOpacity()

Fix the opacity value (0 to 1) for PNG alpha value.

public static fixPNGOpacity([int|float $opacity = 1 ]) : int
Parameters
$opacity : int|float = 1
Tags
Return values
int

getExtension()

Gets image extension from filename.

public static getExtension(string $filename) : string
Parameters
$filename : string

image path

Tags
Return values
string

return jpg, png or gif extension

getImageType()

Gets image type from filename.

public static getImageType(string $filename) : bool
Parameters
$filename : string

image path

Tags
Return values
bool

getMimetype()

Gets image mimeType by filename.

public static getMimetype(string $filename) : string
Parameters
$filename : string

image path

Tags
Return values
string

getMimetypeByImageType()

Gets image mime type by image type (IMAGETYPE_GIF, IMAGETYPE_PNG or IMAGETYPE_JPEG).

public static getMimetypeByImageType(string $imagetype) : string
Parameters
$imagetype : string

IMAGETYPE_GIF, IMAGETYPE_PNG or IMAGETYPE_JPEG

Tags
Return values
string

getMimetypes()

Gets image mime types (jpg, png and gif).

public static getMimetypes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

isGIF()

Checks if image path is a PNG.

public static isGIF(string $filename) : bool
Parameters
$filename : string

image path

Tags
Return values
bool

isJPG()

Checks if image path is a JPG.

public static isJPG(string $filename) : bool
Parameters
$filename : string

image path

Tags
Return values
bool

isJPGResource()

Checks if image resource is a JPG.

public static isJPGResource(string $resource) : bool
Parameters
$resource : string

image resource

Tags
Return values
bool

isPNG()

Checks if image path is a PNG.

public static isPNG(string $filename) : bool
Parameters
$filename : string

image path

Tags
Return values
bool

isPNGResource()

Checks if image resource is a PNG.

public static isPNGResource(string $resource) : bool
Parameters
$resource : string

image resource

Tags
Return values
bool

        

Search results