PHP Класс 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.
Автор: Chuck Hagenbuch ([email protected])
Автор: Michael J. Rubinsky ([email protected])
Наследование: implements Iterator
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$_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

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
_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

Описание методов

__construct() публичный Метод

Const'r
public __construct ( array $image = [] ) : Ansel_Image
$image array
Результат Ansel_Image

_autoRotate() защищенный Метод

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

_buildImageObject() защищенный Метод

Used to wrap iterating the Horde_Image
protected _buildImageObject ( Horde_Image_Base $image ) : Ansel_Image
$image Horde_Image_Base The Horde_Image
Результат Ansel_Image

_exifToTags() защищенный Метод

Called during image upload/creation.
protected _exifToTags ( array $fields = [] ) : void
$fields array An array of EXIF fields to import as a tag.
Результат void

_writeData() защищенный Метод

Writes the current data to vfs, used when creating a new image
protected _writeData ( ) : boolean
Результат boolean

addEffect() публичный Метод

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() публичный Метод

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

createView() публичный Метод

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() публичный Метод

Crop this image to desired dimensions. Crops the currently loaded view present in the Horde_Image object.
См. также: 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() публичный Метод

Return the current image from the internal iterator.
public current ( ) : Ansel_Image
Результат Ansel_Image

deleteCache() публичный Метод

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

display() публичный Метод

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() публичный Метод

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

flip() публичный Метод

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

geotag() публичный Метод

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() публичный Метод

Get the image attributes from the backend.
public getAttributes ( ) : array
Результат array A hash of Exif fieldnames => values.

getDimensions() публичный Метод

Returns the dimensions of the given view.
public getDimensions ( string $view = 'full' ) : array
$view string The view (full, screen etc..) to get dimensions for
Результат array A hash of 'width and 'height' dimensions.

getEXIF() публичный Метод

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.
Результат boolean True if any local properties were modified, False if not.

getHordeImage() публичный Метод

Obtain a reference to the underlying Horde_Image
public getHordeImage ( ) : Horde_Image_Base
Результат Horde_Image_Base

getImagePageCount() публичный Метод

Get the number of pages that a multipage image contains.
public getImagePageCount ( ) : integer
Результат integer The number of pages.

getTags() публичный Метод

Returns this image's tags.
См. также: Ansel_Tags::readTags()
public getTags ( ) : array
Результат array An array of tags

getTile() публичный Метод

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.
Результат string HTML for this image's view tile.

getType() публичный Метод

Get the image type for the requested view.
public getType ( $view = 'full' ) : string
Результат string The requested view's mime type

getVFSName() публичный Метод

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).
Результат string This image's VFS file name.

getVFSPath() публичный Метод

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.
Результат string The vfs path for this image.

getVFSPathFromHash() публичный Метод

Generate a path on the VFS given a known style hash.
public getVFSPathFromHash ( string $hash ) : string
$hash string The sytle hash
Результат string the VFS path to the directory for the provided hash

getViewHash() публичный Метод

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.
Результат string A md5 hash suitable for use as a key.

grayscale() публичный Метод

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

isMultiPage() публичный Метод

Indicates if this image represents a multipage image.
public isMultiPage ( ) : boolean
Результат boolean

key() публичный Метод

Get the index of the internal iterator.
public key ( ) : integer
Результат integer

load() публичный Метод

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() публичный Метод

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

next() публичный Метод

Advance the iterator
public next ( ) : mixed
Результат mixed Ansel_Image or false if not valid()

raw() публичный Метод

Returns the raw data for the given view.
public raw ( string $view = 'full' ) : string
$view string Which view to return.
Результат string The raw binary image data

removeTag() публичный Метод

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

replace() публичный Метод

Replace this image's image data.
public replace ( array $imageData ) : void
$imageData array An array of image data, the same keys as Const'r
Результат void

reset() публичный Метод

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

resize() публичный Метод

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() публичный Метод

Reset the iterator to the first image in the set.
public rewind ( ) : void
Результат void

rotate() публичный Метод

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() публичный Метод

Save image details to storage.
public save ( ) : integer
Результат integer image id

setTags() публичный Метод

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() публичный Метод

Wraps the given view into a file.
Устаревший: Not used anywhere, remove in A4.
public toFile ( string $view = 'full' ) : string
$view string Which view to wrap up.
Результат string Path to temporary file.

updateData() публичный Метод

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() публичный Метод

Deterimines if the current iterator item is valid.
public valid ( ) : boolean
Результат boolean

viewExists() публичный статический Метод

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
Результат mixed False if image does not exists | string vfs name

watermark() публичный Метод

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).

Описание свойств

$_data защищенное свойство

Binary image data for loaded views
protected array $_data
Результат array

$_dirty защищенное свойство

Dirty flag
protected bool $_dirty
Результат boolean

$_exif защищенное свойство

Cache the raw EXIF data locally
protected array $_exif
Результат array

$_image защищенное свойство

Horde_Image object for this image.
protected Horde_Image_Base $_image
Результат Horde_Image_Base

$_loaded защищенное свойство

Flags for loaded views
protected array $_loaded
Результат array

$_tags защищенное свойство

Holds an array of tags for this image
protected array $_tags
Результат array

$caption публичное свойство

Image caption
public string $caption
Результат string

$commentCount публичное свойство

The number of comments for this image, if available.
public int $commentCount
Результат integer

$facesCount публичное свойство

Number of faces in this image
public int $facesCount
Результат integer

$filename публичное свойство

The filename for this image
public string $filename
Результат string

$geotag_timestamp публичное свойство

Timestamp for when image was geotagged
public int $geotag_timestamp
Результат integer

$id публичное свойство

Image Id
public int $id
Результат integer

$lat публичное свойство

Latitude
public string $lat
Результат string

$lng публичное свойство

Longitude
public string $lng
Результат string

$location публичное свойство

Textual location
public string $location
Результат string

$originalDate публичное свойство

Timestamp of original date.
public int $originalDate
Результат integer

$sort публичное свойство

Sort count for this image
public int $sort
Результат integer

$type публичное свойство

The image's mime type
public string $type
Результат string

$uploaded публичное свойство

Timestamp of uploaded datetime
public int $uploaded
Результат integer