PreviewProcessing

final class \TYPO3\CMS\Core\Resource\OnlineMedia\Processing\PreviewProcessing

Extends
LocalImageProcessor
Implements
ProcessorInterface

Preview of Online Media item Processing

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Interfaces

ProcessorInterface
Interface for file processors. All classes capable of processing a file have to implement this interface.

Methods

__construct()  : mixed
canProcessTask()  : bool
Returns TRUE if this processor can process the given task.
processTask()  : void
Processes the given task.
checkForExistingTargetFile()  : bool
Check if the target file that is to be processed already exists.
createPreviewPlaceholder()  : array
Delivers a static SVG placeholder as processing result in case no preview can be generated, so any thumbnail consumer still receives a valid image URL.
createTemporaryLocalCopy()  : string
A resource outside the File Abstraction Layer deliberately exposes no local path of its own (SystemResourceInterface has none) - GraphicalFunctions needs one regardless, since it shells out to ImageMagick/GraphicsMagick, so this writes its content to a private temporary file instead. The caller is responsible for removing it once done - unlike a FAL File's local copy, nothing else owns or later cleans this one up.
generatePreviewFromFile()  : array
Generates a preview for a file
generatePreviewFromLocalFile()  : array
Generates a preview for a local file
generateProcessedFileNameWithoutExtension()  : string
Generate the name of the new File. Should be placed somwhere else?
getConcreteSourceFile()  : File
Some call sites (checkForExistingTargetFile()) are genuinely FAL-only - there is no non-FAL equivalent of a ResourceStorage processing folder. Narrow back to a concrete File/ProcessedFile there, rather than at every such call site.
getConcreteTargetFile()  : ProcessedFile
getFilenameForImageCropScaleMask()  : string
Returns the filename for a cropped/scaled/masked file which will be put in typo3temp for the time being.
getLocalPathOfMaskImage()  : string
isMaskImage()  : bool
A mask is a FAL file, or a processed resource outside the File Abstraction Layer (e.g. a scaled EXT:/PKG: system resource).
processCropScaleMask()  : array|null
This method actually does the processing of files locally
processCropScaleMaskWithLocalFile()  : array|null
Does the heavy lifting prescribed in processTask() except that the processing can be performed on any given local image.
processPreview()  : array|null
This method actually does the processing of files locally
processPreviewWithLocalFile()  : array|null
Does the heavy lifting prescribed in processTask() except that the processing can be performed on any given local image
processTaskWithLocalFile()  : void
Processes an image described in a task, but optionally uses a given local image

Methods

canProcessTask()

Returns TRUE if this processor can process the given task.

public canProcessTask(TaskInterface $task) : bool

Parameters

$task : TaskInterface

Return values

bool

checkForExistingTargetFile()

Check if the target file that is to be processed already exists.

protected checkForExistingTargetFile(TaskInterface $task) : bool

If it exists, use the metadata from that file and mark task as done.

Parameters

$task : TaskInterface

Return values

bool

createPreviewPlaceholder()

Delivers a static SVG placeholder as processing result in case no preview can be generated, so any thumbnail consumer still receives a valid image URL.

protected createPreviewPlaceholder() : array

Return values

array

createTemporaryLocalCopy()

A resource outside the File Abstraction Layer deliberately exposes no local path of its own (SystemResourceInterface has none) - GraphicalFunctions needs one regardless, since it shells out to ImageMagick/GraphicsMagick, so this writes its content to a private temporary file instead. The caller is responsible for removing it once done - unlike a FAL File's local copy, nothing else owns or later cleans this one up.

protected createTemporaryLocalCopy(SystemResourceInterface $sourceFile) : string

Parameters

$sourceFile : SystemResourceInterface

Return values

string

generatePreviewFromFile()

Generates a preview for a file

protected generatePreviewFromFile(File $file, array $configuration) : array

Parameters

$file : File

The source file

$configuration : array

Processing configuration

Return values

array

generatePreviewFromLocalFile()

Generates a preview for a local file

protected generatePreviewFromLocalFile(string $originalFileName, array $configuration) : array

Parameters

$originalFileName : string

Input file path

$configuration : array

Processing configuration

Return values

array

generateProcessedFileNameWithoutExtension()

Generate the name of the new File. Should be placed somwhere else?

protected generateProcessedFileNameWithoutExtension(TaskInterface $task) : string

Parameters

$task : TaskInterface

Return values

string

getConcreteSourceFile()

Some call sites (checkForExistingTargetFile()) are genuinely FAL-only - there is no non-FAL equivalent of a ResourceStorage processing folder. Narrow back to a concrete File/ProcessedFile there, rather than at every such call site.

protected getConcreteSourceFile(TaskInterface $task) : File

Parameters

$task : TaskInterface

Return values

File

getFilenameForImageCropScaleMask()

Returns the filename for a cropped/scaled/masked file which will be put in typo3temp for the time being.

protected getFilenameForImageCropScaleMask(TaskInterface $task) : string

Parameters

$task : TaskInterface

Return values

string

isMaskImage()

A mask is a FAL file, or a processed resource outside the File Abstraction Layer (e.g. a scaled EXT:/PKG: system resource).

protected isMaskImage(mixed $maskImage) : bool

Parameters

$maskImage : mixed

Return values

bool

processCropScaleMask()

This method actually does the processing of files locally

protected processCropScaleMask(TaskInterface $task) : array|null

Takes the original file (for remote storages this will be fetched from the remote server), does the IM magic on the local server by creating a temporary typo3temp/ file, copies the typo3temp/ file to the processing folder of the target storage and removes the typo3temp/ file.

The returned array has the following structure: width => 100 height => 200 filePath => /some/path

If filePath isn't set but width and height are the original file is used as ProcessedFile with the returned width and height. This is for example useful for SVG images.

Parameters

$task : TaskInterface

Return values

array|null

processCropScaleMaskWithLocalFile()

Does the heavy lifting prescribed in processTask() except that the processing can be performed on any given local image.

protected processCropScaleMaskWithLocalFile(TaskInterface $task, string $originalFileName) : array|null

Note that the resize() method usually does not upscale images (depends on "noScale" option), so the original file would be used for the processor result.

Parameters

$task : TaskInterface
$originalFileName : string

Return values

array|null

processPreview()

This method actually does the processing of files locally

protected processPreview(TaskInterface $task) : array|null

takes the original file (on remote storages this will be fetched from the remote server) does the IM magic on the local server by creating a temporary typo3temp/ file copies the typo3temp/ file to the processing folder of the target storage removes the typo3temp/ file

The returned array has the following structure: width => 100 height => 200 filePath => /some/path

If filePath isn't set but width and height are the original file is used as ProcessedFile with the returned width and height. This is for example useful for SVG images.

Parameters

$task : TaskInterface

Return values

array|null

processPreviewWithLocalFile()

Does the heavy lifting prescribed in processTask() except that the processing can be performed on any given local image

protected processPreviewWithLocalFile(TaskInterface $task, string $localFile) : array|null

Parameters

$task : TaskInterface
$localFile : string

Return values

array|null

processTaskWithLocalFile()

Processes an image described in a task, but optionally uses a given local image

protected processTaskWithLocalFile(TaskInterface $task, string|null $localFile) : void

Parameters

$task : TaskInterface
$localFile : string|null

Tags

throws
InvalidArgumentException
On this page