PHP Class Ansel_Image, horde

Copyright 2001-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.
Author: Chuck Hagenbuch ([email protected])
Author: Michael J. Rubinsky ([email protected])
Inheritance: implements Iterator
Afficher le fichier Open project: horde/horde Class Usage Examples

Méthodes publiques

Свойство Type Description
$caption string Image caption
$commentCount integer The number of comments for this image, if available.
$facesCount integer Number of faces in this image
$filename string The filename for this image
$gallery integer The gallery id of this image's parent gallery
$geotag_timestamp integer Timestamp for when image was geotagged
$id integer Image Id
$lat string Latitude
$lng string Longitude
$location string Textual location
$originalDate integer Timestamp of original date.
$sort integer Sort count for this image
$type string The image's mime type
$uploaded integer Timestamp of uploaded datetime

Protected Properties

Свойство Type Description
$_data array Binary image data for loaded views
$_dirty boolean Dirty flag
$_exif array Cache the raw EXIF data locally
$_image Horde_Image_Base Horde_Image object for this image.
$_loaded array Flags for loaded views
$_tags array Holds an array of tags for this image

Méthodes publiques

Méthode Description
__construct ( array $image = [] ) : Ansel_Image Const'r
addEffect ( string $type, array $params = [] ) Add an effect to the effect stack
applyEffects ( ) Apply any pending effects to the underlaying Horde_Image
createView ( string $view, Ansel_Style $style = null, $watermark = '' ) Creates and caches the given view.
crop ( integer $x1, integer $y1, integer $x2, integer $y2 ) Crop this image to desired dimensions. Crops the currently loaded view present in the Horde_Image object.
current ( ) : Ansel_Image Return the current image from the internal iterator.
deleteCache ( string $view = 'all' ) Deletes the specified cache file.
display ( string $view = 'full', Ansel_Style $style = null ) Display the requested view.
downloadHeaders ( string $view = 'full' ) Sends the correct HTTP headers to the browser to download this image.
flip ( string $view = 'full' ) Flips the image.
geotag ( string $lat, string $lng, string $location = '' ) Update the image's geotag data. Saves to backend storage as well, so no need to call self::save()
getAttributes ( ) : array Get the image attributes from the backend.
getDimensions ( string $view = 'full' ) : array Returns the dimensions of the given view.
getEXIF ( boolean $replacing = false ) : boolean Reads the EXIF data from the image, caches in the object and writes to storage. Also populates any local properties that come from the EXIF data.
getHordeImage ( ) : Horde_Image_Base Obtain a reference to the underlying Horde_Image
getImagePageCount ( ) : integer Get the number of pages that a multipage image contains.
getTags ( ) : array Returns this image's tags.
getTile ( Ansel_Gallery $parent = null, Ansel_Style $style = null, boolean $mini = false, array $params = [] ) : string Get the Ansel_View_Image_Thumb object
getType ( $view = 'full' ) : string Get the image type for the requested view.
getVFSName ( string $view ) : string Returns the file name of this image as used in the VFS backend.
getVFSPath ( string $view = 'full', Ansel_Style $style = null ) : string Return the vfs path for this image.
getVFSPathFromHash ( string $hash ) : string Generate a path on the VFS given a known style hash.
getViewHash ( string $view, Ansel_Style $style = null ) : string Return a hash key for the given view and style.
grayscale ( string $view = 'full' ) Converts the image to grayscale.
isMultiPage ( ) : boolean Indicates if this image represents a multipage image.
key ( ) : integer Get the index of the internal iterator.
load ( string $view = 'full', Ansel_Style $style = null ) Loads the given view into memory.
mirror ( string $view = 'full' ) Mirrors the image.
next ( ) : mixed Advance the iterator
raw ( string $view = 'full' ) : string Returns the raw data for the given view.
removeTag ( string $tag ) Remove a single tag from this image's tag collection
replace ( array $imageData ) : void Replace this image's image data.
reset ( ) Reset the image, removing all loaded views.
resize ( integer $width, integer $height, boolean $ratio = true, boolean $keepProfile = false ) Resize the current image.
rewind ( ) : void Reset the iterator to the first image in the set.
rotate ( string $view = 'full', integer $angle = 90 ) Rotates the image.
save ( ) : integer Save image details to storage.
setTags ( array $tags, boolean $replace = true ) Either add or replace this image's tags.
toFile ( string $view = 'full' ) : string Wraps the given view into a file.
updateData ( string $data, string $view = 'full' ) Change the image data. Deletes old cache and writes the new data to the VFS. Used when updating an image
valid ( ) : boolean Deterimines if the current iterator item is valid.
viewExists ( integer $id, string $view, Ansel_Style $style ) : mixed Check if an image view exists and returns the vfs name complete with the hash directory name prepended if appropriate.
watermark ( string $view = 'full', string $watermark = null, string $halign = null, string $valign = null, string $font = null ) Watermarks the image.

Méthodes protégées

Méthode Description
_autoRotate ( $orientation ) Autorotate based on EXIF orientation field. Updates the data in memory only.
_buildImageObject ( Horde_Image_Base $image ) : Ansel_Image Build an Ansel_Image from a given Horde_Image.
_exifToTags ( array $fields = [] ) : void Adds specified EXIF fields to this image's tags.
_writeData ( ) : boolean Writes the current data to vfs, used when creating a new image

Method Details

__construct() public méthode

Const'r
public __construct ( array $image = [] ) : Ansel_Image
$image array
Résultat Ansel_Image

_autoRotate() protected méthode

Autorotate based on EXIF orientation field. Updates the data in memory only.
protected _autoRotate ( $orientation )

_buildImageObject() protected méthode

Used to wrap iterating the Horde_Image
protected _buildImageObject ( Horde_Image_Base $image ) : Ansel_Image
$image Horde_Image_Base The Horde_Image
Résultat Ansel_Image

_exifToTags() protected méthode

Called during image upload/creation.
protected _exifToTags ( array $fields = [] ) : void
$fields array An array of EXIF fields to import as a tag.
Résultat void

_writeData() protected méthode

Writes the current data to vfs, used when creating a new image
protected _writeData ( ) : boolean
Résultat boolean

addEffect() public méthode

Add an effect to the effect stack
public addEffect ( string $type, array $params = [] )
$type string The effect to add.
$params array The effect parameters.

applyEffects() public méthode

Apply any pending effects to the underlaying Horde_Image
public applyEffects ( )

createView() public méthode

Creates and caches the given view.
public createView ( string $view, Ansel_Style $style = null, $watermark = '' )
$view string Which view to create.
$style Ansel_Style A style object

crop() public méthode

Crop this image to desired dimensions. Crops the currently loaded view present in the Horde_Image object.
See also: Horde_Image_Base::crop for explanation of parameters
public crop ( integer $x1, integer $y1, integer $x2, integer $y2 )
$x1 integer
$y1 integer
$x2 integer
$y2 integer

current() public méthode

Return the current image from the internal iterator.
public current ( ) : Ansel_Image
Résultat Ansel_Image

deleteCache() public méthode

If none is specified, deletes all of the cache files.
public deleteCache ( string $view = 'all' )
$view string Which cache file to delete.

display() public méthode

Display the requested view.
public display ( string $view = 'full', Ansel_Style $style = null )
$view string Which view to display.
$style Ansel_Style Force use of this gallery style.

downloadHeaders() public méthode

Sends the correct HTTP headers to the browser to download this image.
public downloadHeaders ( string $view = 'full' )
$view string The view to download.

flip() public méthode

Flips the image.
public flip ( string $view = 'full' )
$view string The view to work with.

geotag() public méthode

Update the image's geotag data. Saves to backend storage as well, so no need to call self::save()
public geotag ( string $lat, string $lng, string $location = '' )
$lat string Latitude
$lng string Longitude
$location string Textual location

getAttributes() public méthode

Get the image attributes from the backend.
public getAttributes ( ) : array
Résultat array A hash of Exif fieldnames => values.

getDimensions() public méthode

Returns the dimensions of the given view.
public getDimensions ( string $view = 'full' ) : array
$view string The view (full, screen etc..) to get dimensions for
Résultat array A hash of 'width and 'height' dimensions.

getEXIF() public méthode

Reads the EXIF data from the image, caches in the object and writes to storage. Also populates any local properties that come from the EXIF data.
public getEXIF ( boolean $replacing = false ) : boolean
$replacing boolean Set to true if we are replacing the exif data.
Résultat boolean True if any local properties were modified, False if not.

getHordeImage() public méthode

Obtain a reference to the underlying Horde_Image
public getHordeImage ( ) : Horde_Image_Base
Résultat Horde_Image_Base

getImagePageCount() public méthode

Get the number of pages that a multipage image contains.
public getImagePageCount ( ) : integer
Résultat integer The number of pages.

getTags() public méthode

Returns this image's tags.
See also: Ansel_Tags::readTags()
public getTags ( ) : array
Résultat array An array of tags

getTile() public méthode

Get the Ansel_View_Image_Thumb object
public getTile ( Ansel_Gallery $parent = null, Ansel_Style $style = null, boolean $mini = false, array $params = [] ) : string
$parent Ansel_Gallery The parent Ansel_Gallery object.
$style Ansel_Style A gallery definition to use.
$mini boolean Force the use of a mini thumbnail?
$params array Any additional parameters the Ansel_Tile object may need.
Résultat string HTML for this image's view tile.

getType() public méthode

Get the image type for the requested view.
public getType ( $view = 'full' ) : string
Résultat string The requested view's mime type

getVFSName() public méthode

Returns the file name of this image as used in the VFS backend.
public getVFSName ( string $view ) : string
$view string The image view (full, screen, thumb, mini).
Résultat string This image's VFS file name.

getVFSPath() public méthode

Return the vfs path for this image.
public getVFSPath ( string $view = 'full', Ansel_Style $style = null ) : string
$view string The view we want.
$style Ansel_Style A gallery style.
Résultat string The vfs path for this image.

getVFSPathFromHash() public méthode

Generate a path on the VFS given a known style hash.
public getVFSPathFromHash ( string $hash ) : string
$hash string The sytle hash
Résultat string the VFS path to the directory for the provided hash

getViewHash() public méthode

Return a hash key for the given view and style.
public getViewHash ( string $view, Ansel_Style $style = null ) : string
$view string The view (thumb, prettythumb etc...)
$style Ansel_Style The style.
Résultat string A md5 hash suitable for use as a key.

grayscale() public méthode

Converts the image to grayscale.
public grayscale ( string $view = 'full' )
$view string The view (screen, full, etc...) to work with.

isMultiPage() public méthode

Indicates if this image represents a multipage image.
public isMultiPage ( ) : boolean
Résultat boolean

key() public méthode

Get the index of the internal iterator.
public key ( ) : integer
Résultat integer

load() public méthode

Loads the given view into memory.
public load ( string $view = 'full', Ansel_Style $style = null )
$view string Which view to load.
$style Ansel_Style The gallery style.

mirror() public méthode

Mirrors the image.
public mirror ( string $view = 'full' )
$view string The view (size) to work with.

next() public méthode

Advance the iterator
public next ( ) : mixed
Résultat mixed Ansel_Image or false if not valid()

raw() public méthode

Returns the raw data for the given view.
public raw ( string $view = 'full' ) : string
$view string Which view to return.
Résultat string The raw binary image data

removeTag() public méthode

Remove a single tag from this image's tag collection
public removeTag ( string $tag )
$tag string The tag name to remove.

replace() public méthode

Replace this image's image data.
public replace ( array $imageData ) : void
$imageData array An array of image data, the same keys as Const'r
Résultat void

reset() public méthode

Reset the image, removing all loaded views.
public reset ( )

resize() public méthode

Resize the current image.
public resize ( integer $width, integer $height, boolean $ratio = true, boolean $keepProfile = false )
$width integer The new width.
$height integer The new height.
$ratio boolean Maintain original aspect ratio.
$keepProfile boolean Keep the image meta data.

rewind() public méthode

Reset the iterator to the first image in the set.
public rewind ( ) : void
Résultat void

rotate() public méthode

Rotates the image.
public rotate ( string $view = 'full', integer $angle = 90 )
$view string The view (size) to work with.
$angle integer What angle to rotate the image by.

save() public méthode

Save image details to storage.
public save ( ) : integer
Résultat integer image id

setTags() public méthode

Either add or replace this image's tags.
public setTags ( array $tags, boolean $replace = true )
$tags array An array of tag names
$replace boolean Replace all tags with those provided.

toFile() public méthode

Wraps the given view into a file.
Deprecation: Not used anywhere, remove in A4.
public toFile ( string $view = 'full' ) : string
$view string Which view to wrap up.
Résultat string Path to temporary file.

updateData() public méthode

Change the image data. Deletes old cache and writes the new data to the VFS. Used when updating an image
public updateData ( string $data, string $view = 'full' )
$data string The new data for this image.
$view string If specified, the $data represents only this particular view. Cache will not be deleted.

valid() public méthode

Deterimines if the current iterator item is valid.
public valid ( ) : boolean
Résultat boolean

viewExists() public static méthode

Check if an image view exists and returns the vfs name complete with the hash directory name prepended if appropriate.
public static viewExists ( integer $id, string $view, Ansel_Style $style ) : mixed
$id integer Image id to check
$view string Which view to check for
$style Ansel_Style Style object
Résultat mixed False if image does not exists | string vfs name

watermark() public méthode

Watermarks the image.
public watermark ( string $view = 'full', string $watermark = null, string $halign = null, string $valign = null, string $font = null )
$view string The view (size) to work with.
$watermark string String to use as the watermark.
$halign string Horizontal alignment (Left, Right, Center)
$valign string Vertical alignment (Top, Center, Bottom)
$font string The font to use (not all image drivers will support this).

Property Details

$_data protected_oe property

Binary image data for loaded views
protected array $_data
Résultat array

$_dirty protected_oe property

Dirty flag
protected bool $_dirty
Résultat boolean

$_exif protected_oe property

Cache the raw EXIF data locally
protected array $_exif
Résultat array

$_image protected_oe property

Horde_Image object for this image.
protected Horde_Image_Base $_image
Résultat Horde_Image_Base

$_loaded protected_oe property

Flags for loaded views
protected array $_loaded
Résultat array

$_tags protected_oe property

Holds an array of tags for this image
protected array $_tags
Résultat array

$caption public_oe property

Image caption
public string $caption
Résultat string

$commentCount public_oe property

The number of comments for this image, if available.
public int $commentCount
Résultat integer

$facesCount public_oe property

Number of faces in this image
public int $facesCount
Résultat integer

$filename public_oe property

The filename for this image
public string $filename
Résultat string

$geotag_timestamp public_oe property

Timestamp for when image was geotagged
public int $geotag_timestamp
Résultat integer

$id public_oe property

Image Id
public int $id
Résultat integer

$lat public_oe property

Latitude
public string $lat
Résultat string

$lng public_oe property

Longitude
public string $lng
Résultat string

$location public_oe property

Textual location
public string $location
Résultat string

$originalDate public_oe property

Timestamp of original date.
public int $originalDate
Résultat integer

$sort public_oe property

Sort count for this image
public int $sort
Résultat integer

$type public_oe property

The image's mime type
public string $type
Résultat string

$uploaded public_oe property

Timestamp of uploaded datetime
public int $uploaded
Résultat integer