ImageMagickFile
Value object for file to be used for ImageMagick/GraphicsMagick invocation when being used as input file (implies and requires that file exists for some evaluations).
Table of Contents
Properties
- $allowedExtensions : array<string|int, string>
- File extensions that directly can be used (and are considered to be safe).
- $asArgument : string
- Result to be used for ImageMagick/GraphicsMagick invocation containing combination of resolved format prefix, $filePath and frame escaped to be used as CLI argument (e.g. "'png:file.png'")
- $deniedExtensions : array<string|int, string>
- File extensions that never shall be used.
- $fileExists : bool
- Whether file actually exists
- $fileExtension : string
- File extension as given in $filePath (e.g. 'file.png' -> 'png')
- $filePath : string
- Path to input file to be processed
- $frame : int|null
- Frame to be used (of multi-page document, e.g. PDF)
- $mimeExtensions : array<string|int, string>
- Resolved extension for mime-type (e.g. 'image/png' -> 'png') (might be empty if not defined in magic.mime database)
- $mimeType : string|null
- Resolved mime-type of file
- $mimeTypeExtensionMap : array<string|int, string>
- File mime-types that have to be matching. Adding custom mime-types is possible using $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']
Methods
- __construct() : mixed
- __toString() : string
- fromFilePath() : ImageMagickFile
- escape() : string
- getFileInfo() : FileInfo
- isInAllowedExtensions() : bool
- resolvePrefix() : string
- Resolves according ImageMagic/GraphicsMagic format (e.g. 'png:', 'jpg:', ...).
Properties
$allowedExtensions
File extensions that directly can be used (and are considered to be safe).
protected
array<string|int, string>
$allowedExtensions
= ['png', 'jpg', 'jpeg', 'gif', 'webp', 'tif', 'tiff', 'bmp', 'pcx', 'tga', 'ico']
$asArgument
Result to be used for ImageMagick/GraphicsMagick invocation containing combination of resolved format prefix, $filePath and frame escaped to be used as CLI argument (e.g. "'png:file.png'")
protected
string
$asArgument
$deniedExtensions
File extensions that never shall be used.
protected
array<string|int, string>
$deniedExtensions
= ['epi', 'eps', 'eps2', 'eps3', 'epsf', 'epsi', 'ept', 'ept2', 'ept3', 'msl', 'ps', 'ps2', 'ps3']
$fileExists
Whether file actually exists
protected
bool
$fileExists
$fileExtension
File extension as given in $filePath (e.g. 'file.png' -> 'png')
protected
string
$fileExtension
$filePath
Path to input file to be processed
protected
string
$filePath
$frame
Frame to be used (of multi-page document, e.g. PDF)
protected
int|null
$frame
$mimeExtensions
Resolved extension for mime-type (e.g. 'image/png' -> 'png') (might be empty if not defined in magic.mime database)
protected
array<string|int, string>
$mimeExtensions
= []
Tags
$mimeType
Resolved mime-type of file
protected
string|null
$mimeType
$mimeTypeExtensionMap
File mime-types that have to be matching. Adding custom mime-types is possible using $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']
protected
array<string|int, string>
$mimeTypeExtensionMap
= ['image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/heic' => 'heic', 'image/heif' => 'heif', 'image/webp' => 'webp', 'image/svg' => 'svg', 'image/svg+xml' => 'svg', 'image/tiff' => 'tif', 'application/pdf' => 'pdf']
Tags
Methods
__construct()
public
__construct(string $filePath[, int|null $frame = null ]) : mixed
Parameters
- $filePath : string
- $frame : int|null = null
Tags
__toString()
public
__toString() : string
Return values
stringfromFilePath()
public
static fromFilePath(string $filePath[, int|null $frame = null ]) : ImageMagickFile
Parameters
- $filePath : string
- $frame : int|null = null
Return values
ImageMagickFileescape()
protected
escape(string $value) : string
Parameters
- $value : string
Return values
stringgetFileInfo()
protected
getFileInfo(string $filePath) : FileInfo
Parameters
- $filePath : string
Return values
FileInfoisInAllowedExtensions()
protected
isInAllowedExtensions(string $extension) : bool
Parameters
- $extension : string
Return values
boolresolvePrefix()
Resolves according ImageMagic/GraphicsMagic format (e.g. 'png:', 'jpg:', ...).
protected
resolvePrefix() : string
- in case mime-type could be resolved and is configured, it takes precedence
- otherwise resolved mime-type extension of mime.magick database is used if available (includes custom settings with $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'])
- otherwise "safe" and allowed file extension is used (jpg, png, gif, webp, tif, ...)
- potentially malicious script formats (eps, ps, ...) are not allowed