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

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

 resolvePrefix ()
 escape (string $value)
 isInAllowedExtensions (string $extension)
 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()

TYPO3\CMS\Core\Imaging\ImageMagickFile::__toString ( )

◆ escape()

TYPO3\CMS\Core\Imaging\ImageMagickFile::escape ( string  $value)

◆ fromFilePath()

◆ getFileInfo()

TYPO3\CMS\Core\Imaging\ImageMagickFile::getFileInfo ( string  $filePath)

◆ isInAllowedExtensions()

TYPO3\CMS\Core\Imaging\ImageMagickFile::isInAllowedExtensions ( string  $extension)

◆ resolvePrefix()

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

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

Definition at line 158 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' )

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

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

File extensions that never shall be used.

Definition at line 87 of file ImageMagickFile.php.

◆ $fileExists

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

Whether file actually exists

Definition at line 47 of file ImageMagickFile.php.

◆ $fileExtension

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

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

◆ $frame

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

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

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

See also

Definition at line 67 of file ImageMagickFile.php.

◆ $mimeType

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

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

Definition at line 95 of file ImageMagickFile.php.