‪TYPO3CMS  11.5
TYPO3\CMS\Core\Imaging\ImageMagickFile Class Reference

Public Member Functions

 __construct (string $filePath, ?int $frame=null)
 
string __toString ()
 

Static Public Member Functions

static ImageMagickFile fromFilePath (string $filePath, ?int $frame=null)
 

Protected Member Functions

string resolvePrefix ()
 
string escape (string $value)
 
bool isInAllowedExtensions (string $extension)
 
FileInfo getFileInfo (string $filePath)
 

Protected Attributes

string $filePath
 
int null $frame
 
bool $fileExists
 
string $fileExtension
 
string null $mimeType
 
string[] $mimeExtensions = array( )
 
string $asArgument
 
string[] $allowedExtensions = array( 'png', 'jpg', 'jpeg', 'gif', 'webp', 'tif', 'tiff', 'bmp', 'pcx', 'tga', 'ico' )
 
string[] $deniedExtensions = array( 'epi', 'eps', 'eps2', 'eps3', 'epsf', 'epsi', 'ept', 'ept2', 'ept3', 'msl', 'ps', 'ps2', 'ps3' )
 
string[] $mimeTypeExtensionMap
 

Detailed Description

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

Definition at line 29 of file ImageMagickFile.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Imaging\ImageMagickFile::__construct ( string  $filePath,
?int  $frame = null 
)

Member Function Documentation

◆ __toString()

string TYPO3\CMS\Core\Imaging\ImageMagickFile::__toString ( )
Returns
‪string

Definition at line 149 of file ImageMagickFile.php.

References TYPO3\CMS\Core\Imaging\ImageMagickFile\$asArgument.

◆ escape()

string TYPO3\CMS\Core\Imaging\ImageMagickFile::escape ( string  $value)
protected
Parameters
string$value
Returns
‪string

Definition at line 193 of file ImageMagickFile.php.

References TYPO3\CMS\Core\Utility\CommandUtility\escapeShellArgument().

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\__construct().

◆ fromFilePath()

◆ getFileInfo()

FileInfo TYPO3\CMS\Core\Imaging\ImageMagickFile::getFileInfo ( string  $filePath)
protected
Parameters
string$filePath
Returns
‪FileInfo

Definition at line 211 of file ImageMagickFile.php.

References TYPO3\CMS\Core\Imaging\ImageMagickFile\$filePath.

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\__construct().

◆ isInAllowedExtensions()

bool TYPO3\CMS\Core\Imaging\ImageMagickFile::isInAllowedExtensions ( string  $extension)
protected
Parameters
string$extension
Returns
‪bool

Definition at line 202 of file ImageMagickFile.php.

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\resolvePrefix().

◆ resolvePrefix()

string TYPO3\CMS\Core\Imaging\ImageMagickFile::resolvePrefix ( )
protected

Resolves according ImageMagic/GraphicsMagic format (e.g. 'png:', 'jpg:', ...).

  • ‪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
Returns
‪string
Exceptions
UnsupportedFileException

Definition at line 165 of file ImageMagickFile.php.

References TYPO3\CMS\Core\Imaging\ImageMagickFile\$fileExtension, TYPO3\CMS\Core\Imaging\ImageMagickFile\$mimeType, and TYPO3\CMS\Core\Imaging\ImageMagickFile\isInAllowedExtensions().

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\__construct().

Member Data Documentation

◆ $allowedExtensions

string [] TYPO3\CMS\Core\Imaging\ImageMagickFile::$allowedExtensions = array( 'png', 'jpg', 'jpeg', 'gif', 'webp', 'tif', 'tiff', 'bmp', 'pcx', 'tga', 'ico' )
protected

File extensions that directly can be used (and are considered to be safe).

Definition at line 81 of file ImageMagickFile.php.

◆ $asArgument

string TYPO3\CMS\Core\Imaging\ImageMagickFile::$asArgument
protected

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'")

Definition at line 75 of file ImageMagickFile.php.

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\__toString().

◆ $deniedExtensions

string [] TYPO3\CMS\Core\Imaging\ImageMagickFile::$deniedExtensions = array( 'epi', 'eps', 'eps2', 'eps3', 'epsf', 'epsi', 'ept', 'ept2', 'ept3', 'msl', 'ps', 'ps2', 'ps3' )
protected

File extensions that never shall be used.

Definition at line 87 of file ImageMagickFile.php.

◆ $fileExists

bool TYPO3\CMS\Core\Imaging\ImageMagickFile::$fileExists
protected

Whether file actually exists

Definition at line 47 of file ImageMagickFile.php.

◆ $fileExtension

string TYPO3\CMS\Core\Imaging\ImageMagickFile::$fileExtension
protected

File extension as given in $filePath (e.g. 'file.png' -> 'png')

Definition at line 53 of file ImageMagickFile.php.

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\resolvePrefix().

◆ $filePath

string TYPO3\CMS\Core\Imaging\ImageMagickFile::$filePath
protected

◆ $frame

int null TYPO3\CMS\Core\Imaging\ImageMagickFile::$frame
protected

Frame to be used (of multi-page document, e.g. PDF)

Definition at line 41 of file ImageMagickFile.php.

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\__construct(), and TYPO3\CMS\Core\Imaging\ImageMagickFile\fromFilePath().

◆ $mimeExtensions

string [] TYPO3\CMS\Core\Imaging\ImageMagickFile::$mimeExtensions = array( )
protected

Resolved extension for mime-type (e.g. 'image/png' -> 'png') (might be empty if not defined in magic.mime database)

See also
FileInfo::getMimeExtensions()

Definition at line 67 of file ImageMagickFile.php.

◆ $mimeType

string null TYPO3\CMS\Core\Imaging\ImageMagickFile::$mimeType
protected

Resolved mime-type of file

Definition at line 59 of file ImageMagickFile.php.

Referenced by TYPO3\CMS\Core\Imaging\ImageMagickFile\resolvePrefix().

◆ $mimeTypeExtensionMap

string [] TYPO3\CMS\Core\Imaging\ImageMagickFile::$mimeTypeExtensionMap
protected
Initial value:
= array(
'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',
)

File mime-types that have to be matching. Adding custom mime-types is possible using $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType']

See also
FileInfo::getMimeExtensions()

Definition at line 95 of file ImageMagickFile.php.