Automad
 All Classes Functions Variables Pages
Automad\Core\Image Class Reference

Public Member Functions

 __construct ($originalFile=false, $requestedWidth=false, $requestedHeight=false, $crop=false)
 

Public Attributes

 $originalWidth
 
 $originalHeight
 
 $file
 
 $description
 
 $width
 
 $height
 

Private Member Functions

 calculateSize ()
 
 createImage ()
 
 getDescription ()
 
 getImageCacheFilePath ()
 
 verifyCachedImage ()
 

Private Attributes

 $originalFile
 
 $requestedWidth
 
 $requestedHeight
 
 $crop
 
 $cropX
 
 $cropY
 
 $type
 
 $fileFullPath
 

Detailed Description

The Image object represents a resized (and cropped) copy of a given image.

Author
Marc Anton Dahmen hello.nosp@m.@mar.nosp@m.cdahm.nosp@m.en.d.nosp@m.e
License
MIT license - http://automad.org/license

Definition at line 52 of file image.php.

Constructor & Destructor Documentation

Automad\Core\Image::__construct (   $originalFile = false,
  $requestedWidth = false,
  $requestedHeight = false,
  $crop = false 
)

The constructor defines the main object properties from the given parameters and initiates the main methods.

Definition at line 156 of file image.php.

Member Function Documentation

Automad\Core\Image::calculateSize ( )
private

Calculate the size and pixels to crop for the generated image.

Definition at line 204 of file image.php.

Automad\Core\Image::createImage ( )
private

Create a new (resized and cropped) image from the source image and save that image in AM_DIR_CACHE_IMAGES.

Definition at line 297 of file image.php.

References Automad\Core\Debug\log().

Automad\Core\Image::getDescription ( )
private

Return the description from the JPG's exif data.

Returns
The description string.

Definition at line 360 of file image.php.

Automad\Core\Image::getImageCacheFilePath ( )
private

Determine the corresponding image file to a source file based on a md5 hash. That hash is based on the source image's path, mtime, the new width and height and the cropping parameter. If one parameter changes, the hash will be different, which will result in recreating an image. Since the mtime is part of the hash, also any modification to the source image will be reflected in a different name. For each size and cropping setting, a unique filename will be returned, to clearly identify that setting.

Returns
the matching filename for the requested source image, based on its parameters

Definition at line 386 of file image.php.

References Automad\Core\Debug\log().

Automad\Core\Image::verifyCachedImage ( )
private

To verify, if the requested image is up to date, only the existence has to be tested, since any changes in the source image will be reflected in the filename's hash.

Definition at line 411 of file image.php.

Member Data Documentation

Automad\Core\Image::$crop
private

Cropping parameter.

Definition at line 93 of file image.php.

Automad\Core\Image::$cropX
private

The pixels to crop the image on the X-axis on both sides.

Definition at line 100 of file image.php.

Automad\Core\Image::$cropY
private

The pixels to crop the image on the Y-axis on both sides.

Definition at line 107 of file image.php.

Automad\Core\Image::$description

The image's description, read from the source image's exif data.

Definition at line 135 of file image.php.

Automad\Core\Image::$file

The filename of generated image.

Definition at line 121 of file image.php.

Automad\Core\Image::$fileFullPath
private

The full file system path to the generated image.

Definition at line 128 of file image.php.

Automad\Core\Image::$height

The height of the generated image.

Definition at line 149 of file image.php.

Automad\Core\Image::$originalFile
private

The filename of the source image

Definition at line 58 of file image.php.

Automad\Core\Image::$originalHeight

The height of the source image.

Definition at line 72 of file image.php.

Automad\Core\Image::$originalWidth

The width of the source image.

Definition at line 65 of file image.php.

Automad\Core\Image::$requestedHeight
private

The desired height of the new image. (May not be the resulting width, depending on cropping or original image size)

Definition at line 86 of file image.php.

Automad\Core\Image::$requestedWidth
private

The disired width of the new image. (May not be the resulting width, depending on cropping or original image size)

Definition at line 79 of file image.php.

Automad\Core\Image::$type
private

The given image type.

Definition at line 114 of file image.php.

Automad\Core\Image::$width

The width of the generated image.

Definition at line 142 of file image.php.


The documentation for this class was generated from the following file: