PHP Class Gregwar\Image\Image

Author: Gregwar ([email protected])
Mostra file Open project: Gregwar/Image Class Usage Examples

Public Properties

Property Type Description
$types Supported types.

Protected Properties

Property Type Description
$adapter Gregwar\Image\Adapter\AdapterInterface Internal adapter.
$cache Gregwar\Cache\CacheInterface Cache system.
$cacheDir Directory to use for file caching.
$cacheMode Directory cache mode.
$fallback Fallback image.
$forceCache Force image caching, even if there is no operation applied.
$hash Transformations hash.
$operations Operations array.
$prettyName Pretty name for the image.
$prettyPrefix
$source The image source.
$useFallbackImage Use fallback image.

Public Methods

Method Description
__call ( $methodName, $args ) Generic function.
__construct ( $originalFile = null, $width = null, $height = null )
__toString ( ) Tostring defaults to jpeg.
applyOperations ( ) Applies the operations.
cacheData ( string $type = 'jpg', integer $quality = 80 ) Get cache data (to render the image).
cacheFile ( string $type = 'jpg', integer $quality = 80, $actual = false ) Gets the cache file name and generate it if it does not exists.
correct ( ) Tells if the image is correct.
create ( $width, $height ) Creates an instance of a new resource.
fromData ( $data ) Creates an instance of image from its data.
fromFile ( string $originalFile ) Defines the file only after instantiation.
fromResource ( $resource ) Creates an instance of image from resource.
generateHash ( $type = 'guess', $quality = 80 ) Generates the hash.
get ( $type = 'guess', $quality = 80 ) Get the contents of the image.
getAdapter ( ) : Gregwar\Image\Adapter\AdapterInterface
getCacheFallback ( ) Gets the fallback into the cache dir.
getCacheSystem ( ) : Gregwar\Cache\CacheInterface Get the cache system.
getDependencies ( ) : string[] Get all the files that this image depends on.
getFallback ( ) Gets the fallack image path.
getFilePath ( ) : mixed Get the file path.
getHash ( $type = 'guess', $quality = 80 ) Gets the hash.
gif ( ) Generates and output a gif cached file.
guess ( $quality = 80 ) Generates and output an image using the same type as input.
guessType ( ) Guess the file type.
height ( ) Image height.
html ( $title = '', $type = 'jpg', $quality = 80 ) Returning basic html code for this image.
init ( ) Initialize the adapter.
inline ( $type = 'jpg', $quality = 80 ) Returns the Base64 inlinable representation.
jpeg ( $quality = 80 ) Generates and output a jpeg cached file.
open ( $file = '' ) Creates an instance, usefull for one-line chaining.
png ( ) Generates and output a png cached file.
save ( $file, $type = 'guess', $quality = 80 ) Save the file to a given output.
serializeOperations ( ) Serialization of operations.
setActualCacheDir ( $actualCacheDir ) The actual cache dir.
setAdapter ( $adapter )
setCacheDir ( $cacheDir ) Change the caching directory.
setCacheDirMode ( integer $dirMode )
setCacheSystem ( Gregwar\Cache\CacheInterface $cache ) Set the cache system.
setData ( $data ) Sets the image data.
setFallback ( $fallback = null ) Sets the fallback image to use.
setForceCache ( $forceCache = true ) Enable or disable to force cache even if the file is unchanged.
setPrettyName ( $name, $prefix = true ) Sets the pretty name of the image.
setResource ( $resource ) Sets the resource.
useFallback ( $useFallbackImage = true ) Use the fallback image or not.
width ( ) Image width.

Protected Methods

Method Description
addOperation ( $method, $args ) Adds an operation.
getFilename ( $filename ) Hook to helps to extends and enhance this class.
urlize ( $name ) Urlizes the prettyName.

Method Details

__call() public method

Generic function.
public __call ( $methodName, $args )

__construct() public method

public __construct ( $originalFile = null, $width = null, $height = null )

__toString() public method

Tostring defaults to jpeg.
public __toString ( )

addOperation() protected method

Adds an operation.
protected addOperation ( $method, $args )

applyOperations() public method

Applies the operations.
public applyOperations ( )

cacheData() public method

Get cache data (to render the image).
public cacheData ( string $type = 'jpg', integer $quality = 80 )
$type string the image type
$quality integer the quality (for JPEG)

cacheFile() public method

Note that if it exists, all the image computation process will not be done.
public cacheFile ( string $type = 'jpg', integer $quality = 80, $actual = false )
$type string the image type
$quality integer the quality (for JPEG)

correct() public method

Tells if the image is correct.
public correct ( )

create() public static method

Creates an instance of a new resource.
public static create ( $width, $height )

fromData() public static method

Creates an instance of image from its data.
public static fromData ( $data )

fromFile() public method

Defines the file only after instantiation.
public fromFile ( string $originalFile )
$originalFile string the file path

fromResource() public static method

Creates an instance of image from resource.
public static fromResource ( $resource )

generateHash() public method

Generates the hash.
public generateHash ( $type = 'guess', $quality = 80 )

get() public method

Get the contents of the image.
public get ( $type = 'guess', $quality = 80 )

getAdapter() public method

public getAdapter ( ) : Gregwar\Image\Adapter\AdapterInterface
return Gregwar\Image\Adapter\AdapterInterface

getCacheFallback() public method

Gets the fallback into the cache dir.
public getCacheFallback ( )

getCacheSystem() public method

Get the cache system.
public getCacheSystem ( ) : Gregwar\Cache\CacheInterface
return Gregwar\Cache\CacheInterface

getDependencies() public method

Get all the files that this image depends on.
public getDependencies ( ) : string[]
return string[] this is an array of strings containing all the files that the current Image depends on

getFallback() public method

Gets the fallack image path.
public getFallback ( )

getFilePath() public method

Get the file path.
public getFilePath ( ) : mixed
return mixed a string with the filen name, null if the image does not depends on a file

getFilename() protected method

Hook to helps to extends and enhance this class.
protected getFilename ( $filename )

getHash() public method

Gets the hash.
public getHash ( $type = 'guess', $quality = 80 )

gif() public method

Generates and output a gif cached file.
public gif ( )

guess() public method

Generates and output an image using the same type as input.
public guess ( $quality = 80 )

guessType() public method

Guess the file type.
public guessType ( )

height() public method

Image height.
public height ( )

html() public method

Returning basic html code for this image.
public html ( $title = '', $type = 'jpg', $quality = 80 )

init() public method

Initialize the adapter.
public init ( )

inline() public method

Returns the Base64 inlinable representation.
public inline ( $type = 'jpg', $quality = 80 )

jpeg() public method

Generates and output a jpeg cached file.
public jpeg ( $quality = 80 )

open() public static method

Creates an instance, usefull for one-line chaining.
public static open ( $file = '' )

png() public method

Generates and output a png cached file.
public png ( )

save() public method

Save the file to a given output.
public save ( $file, $type = 'guess', $quality = 80 )

serializeOperations() public method

Serialization of operations.
public serializeOperations ( )

setActualCacheDir() public method

The actual cache dir.
public setActualCacheDir ( $actualCacheDir )

setAdapter() public method

public setAdapter ( $adapter )

setCacheDir() public method

Change the caching directory.
public setCacheDir ( $cacheDir )

setCacheDirMode() public method

public setCacheDirMode ( integer $dirMode )
$dirMode integer

setCacheSystem() public method

Set the cache system.
public setCacheSystem ( Gregwar\Cache\CacheInterface $cache )
$cache Gregwar\Cache\CacheInterface

setData() public method

Sets the image data.
public setData ( $data )

setFallback() public method

Sets the fallback image to use.
public setFallback ( $fallback = null )

setForceCache() public method

Enable or disable to force cache even if the file is unchanged.
public setForceCache ( $forceCache = true )

setPrettyName() public method

Sets the pretty name of the image.
public setPrettyName ( $name, $prefix = true )

setResource() public method

Sets the resource.
public setResource ( $resource )

urlize() protected method

Urlizes the prettyName.
protected urlize ( $name )

useFallback() public method

Use the fallback image or not.
public useFallback ( $useFallbackImage = true )

width() public method

Image width.
public width ( )

Property Details

$adapter protected_oe property

Internal adapter.
protected AdapterInterface,Gregwar\Image\Adapter $adapter
return Gregwar\Image\Adapter\AdapterInterface

$cache protected_oe property

Cache system.
protected CacheInterface,Gregwar\Cache $cache
return Gregwar\Cache\CacheInterface

$cacheDir protected_oe property

Directory to use for file caching.
protected $cacheDir

$cacheMode protected_oe property

Directory cache mode.
protected $cacheMode

$fallback protected_oe property

Fallback image.
protected $fallback

$forceCache protected_oe property

Force image caching, even if there is no operation applied.
protected $forceCache

$hash protected_oe property

Transformations hash.
protected $hash

$operations protected_oe property

Operations array.
protected $operations

$prettyName protected_oe property

Pretty name for the image.
protected $prettyName

$prettyPrefix protected_oe property

protected $prettyPrefix

$source protected_oe property

The image source.
protected $source

$types public_oe static_oe property

Supported types.
public static $types

$useFallbackImage protected_oe property

Use fallback image.
protected $useFallbackImage