ImageHelper

Type
Class
Namespace
Craft
Inherits
Craft\ImageHelper
Since
1.1

Class ImageHelper

See also http://craftcms.com

View source (opens new window)

# Public Methods

Method Description
calculateMissingDimension() Calculates a missing target dimension for an image.
canHaveExifData() Returns whether an image can have EXIF information embedded.
getImageSize() Returns the size of an image based on its file path.
getPngImageInfo() Returns any info that’s embedded in a given PNG file.
getWebSafeFormats() Returns a list of web safe image formats.
isImageManipulatable() Returns whether an image extension is considered manipulatable.
parseSvgSize() Parses SVG data and determines its size (normalized to pixels).

# calculateMissingDimension()

Calculates a missing target dimension for an image.

View source (opens new window)

Arguments

  • $targetWidth
  • $targetHeight
  • $sourceWidth
  • $sourceHeight

Returns

array (opens new window) – Array of the width and height.

Signature

public static array calculateMissingDimension ( $targetWidth, $targetHeight, $sourceWidth, $sourceHeight )

# canHaveExifData()

Returns whether an image can have EXIF information embedded.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public static boolean canHaveExifData ( $filePath )

# getImageSize()

Returns the size of an image based on its file path.

View source (opens new window)

Arguments

Returns

array (opens new window) – [$width, $height]

Signature

public static array getImageSize ( $filePath )

# getPngImageInfo()

Returns any info that’s embedded in a given PNG file. Adapted from https://github.com/ktomk/Miscellaneous/tree/master/get_png_imageinfo.

View source (opens new window)

Arguments

Returns

array (opens new window), boolean (opens new window) – Info embedded in the PNG file, or false if it wasn’t found.

Signature

public static array, boolean getPngImageInfo ( $file )

# getWebSafeFormats()

Returns a list of web safe image formats.

View source (opens new window)

Returns

array (opens new window)

Signature

public static array getWebSafeFormats ( )

# isImageManipulatable()

Returns whether an image extension is considered manipulatable.

View source (opens new window)

Arguments

  • $extension

Returns

boolean (opens new window)

Signature

public static boolean isImageManipulatable ( $extension )

# parseSvgSize()

Parses SVG data and determines its size (normalized to pixels).

View source (opens new window)

Arguments

Returns

array (opens new window) – [$width, $height]

Signature

public static array parseSvgSize ( $svg )

# Constants

Constant Description
EXIF_IFD0_ROTATE_180
EXIF_IFD0_ROTATE_270
EXIF_IFD0_ROTATE_90