Review main Abandoned

83222[TASK] Prevent SVG conversion to pixel format when image cropping

Benjamin Franzke CR 0 V 0 Expert +1294 −15 updated 03/05/24, 22:38

Commit message

This change adds support for SVGs to be processed. They can be
scaled and cropped.

This way, SVGs are now natively used for cropping and scaling
without being limited to being converted to PNGs.

All cropping operations on SVGs will create a processedFile variant,
just like their pixel counterparts. The processed files will
contain SVG wrappers to reset coordinate systems and apply the
cropped viewBox. This way, responsive styling can be applied to
generated images, and processed SVGs can also be used as
background images via <f:uri.image>.

Tests are added for the fluid ViewHelpers as well as TypoScript-
based rendering of assets. Existing tests with wrong "crop"
argument input formatting have been fixed as a drive-by.

Note that SVG cropping is solely based on the "crop" argument,
either passed to a viewHelper or inferred via the
sys_file_reference entry, that the image editor creates.
Other arguments like `width="100c-10"` which are used for
pixel cropping are not evaluated (because they rely on
pixel operations). Also qualifiers like (max/min)(Width/Height) are
ignored as they are not relevant for SVGs because browsers can scale
SVGs dynamically (and lossless).

Fortunately, this change will keep the possibility to rasterize a SVG
to PNG by setting an fileExtension explicitly.
(Remember, not all image processors support converting SVG
to pixel formats; GraphicsMagick should work, ImageMagick needs
additional helpers.)
Example:

```
10 = IMAGE
10.file = 2:/myfile.svg
10.file.crop = 20,20,500,500
10.file.ext = png
```

Review

  • Code review CR 0

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V 0

    Imported before Forger kept the single votes, the next import adds them.

Files 15