ImageInfo

class \TYPO3\CMS\Core\Type\File\ImageInfo

Extends
FileInfo
Implements
LoggerAwareInterface
Uses
LoggerAwareTrait

An SPL FileInfo class providing information related to an image.

Tags

todo:

This is a broken construct. ImageInfo (via FileInfo) extends \SplFileInfo, a pure data object whose only state is the file path passed to its constructor. FileInfo and ImageInfo then bolt service aspects (mime detection, image size extraction, SVG/graphics processing pulled in via makeInstance) onto that data object, which is why those collaborators cannot be injected and have to be fetched via GeneralUtility::makeInstance(). This should be refactored by splitting the service aspect away from the data object: a slim path/metadata value object, plus a separate injectable service that resolves image information for a given file.

Table of Contents

Interfaces

LoggerAwareInterface

Properties

$imageSizes  : array{0: int<0, max>|string, 1: int<0, max>|string, 2?: string, 3?: string, 4?: string}|false|null

Methods

getHeight()  : int<0, max>
Returns the height of the image.
getMimeExtensions()  : string[]
Returns the file extensions appropriate for a the MIME type detected in the file. For types that commonly have multiple file extensions, such as JPEG images, then the return value is multiple extensions, for instance that could be ['jpeg', 'jpg', 'jpe', 'jiff']. For unknown types not available in the magic.mime database (/etc/magic.mime, /etc/mime.types, ...), then return value is an empty array.
getMimeType()  : string|false
Return the mime type of a file.
getWidth()  : int<0, max>
Returns the width of the image.
extractSvgImageSizes()  : array{0: int<0, max>, 1: int<0, max>}|false
Tries to read SVG as XML file and find width and height.
getExifAwareImageSize()  : array{0: int<0, max>, 1: int<0, max>}|false
Gets the image size, considering the exif-rotation present in the file
getImageSizes()  : array{0: int<0, max>|string, 1: int<0, max>|string, 2?: string, 3?: string, 4?: string}
getImageSizesFromImageMagick()  : array{0: string, 1: string, 2: string, 3: string, 4: string}|null

Properties

$imageSizes

protected array{0: int<0, max>|string, 1: int<0, max>|string, 2?: string, 3?: string, 4?: string}|false|null $imageSizes

Methods

getHeight()

Returns the height of the image.

public getHeight() : int<0, max>

Return values

int<0, max>

getMimeExtensions()

Returns the file extensions appropriate for a the MIME type detected in the file. For types that commonly have multiple file extensions, such as JPEG images, then the return value is multiple extensions, for instance that could be ['jpeg', 'jpg', 'jpe', 'jiff']. For unknown types not available in the magic.mime database (/etc/magic.mime, /etc/mime.types, ...), then return value is an empty array.

public getMimeExtensions() : string[]

TYPO3 specific settings in $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'] take precedence over native resolving.

Return values

string[]

getMimeType()

Return the mime type of a file.

public getMimeType([string $targetFileName = '' ]) : string|false

TYPO3 specific settings in $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'] take precedence over native resolving.

Parameters

$targetFileName : string = ''

supplied during uploads (where the concrete file is a temporary extension-less file) and may be used by mimeTypeGuessers to match based on desired file name

Return values

string|false —

Returns the mime type or FALSE if the mime type could not be discovered

getWidth()

Returns the width of the image.

public getWidth() : int<0, max>

Return values

int<0, max>

extractSvgImageSizes()

Tries to read SVG as XML file and find width and height.

protected extractSvgImageSizes() : array{0: int<0, max>, 1: int<0, max>}|false

Return values

array{0: int<0, max>, 1: int<0, max>}|false

getExifAwareImageSize()

Gets the image size, considering the exif-rotation present in the file

protected getExifAwareImageSize(string $imageFile) : array{0: int<0, max>, 1: int<0, max>}|false

Parameters

$imageFile : string

The image filepath

Return values

array{0: int<0, max>, 1: int<0, max>}|false —

an array where [0]/[1] is w/h

getImageSizes()

protected getImageSizes() : array{0: int<0, max>|string, 1: int<0, max>|string, 2?: string, 3?: string, 4?: string}

Return values

array{0: int<0, max>|string, 1: int<0, max>|string, 2?: string, 3?: string, 4?: string}

getImageSizesFromImageMagick()

protected getImageSizesFromImageMagick() : array{0: string, 1: string, 2: string, 3: string, 4: string}|null

Return values

array{0: string, 1: string, 2: string, 3: string, 4: string}|null
On this page