#111431SVG crop is ignored when the crop area starts at the top-left corner (x=0, y=0)
Description
When an SVG file reference has a crop variant whose area starts at x=0 and y=0
(e.g. the left half of the image), the crop is ignored and the original,
uncropped SVG is delivered. Any crop with an offset (e.g. x=0.25) works.
Steps to reproduce (TYPO3 14.3.10):
1. Upload an SVG, e.g. 342 × 160 px.
2. In a content element, crop it in the image manipulation wizard to its left
half, anchored at the top-left corner: {“x”:0,“y”:0,“width”:0.5,“height”:1}.
3. Render it, e.g. <f:image image="{file}" cropvariant="default"></f:image>
or <f:uri image="{file}" cropvariant="default"></f:uri>.
Expected: a processed SVG showing the left half (viewBox cropped, 171 × 160).
Actual: the URL of the original SVG, uncropped.
Cause:
ImageProcessingInstructions::fromProcessingTask() passes the crop dimensions as
$incomingWidth / $incomingHeight to fromCropScaleValues() when a crop is set
($isCropped is computed but never used). At the end of fromCropScaleValues(),
the crop area is reset to null when it has offset 0/0 and the same size as
$incomingWidth / $incomingHeight:
if ((int)$cropArea->getOffsetLeft() = 0
&& (int)$cropArea->getOffsetTop() = 0
&& (int)$cropArea->getWidth() = $incomingWidth
&& (int)$cropArea->getHeight() = $incomingHeight) {
$cropArea = null;
}
Since $incomingWidth / $incomingHeight are the crop’s own size, this condition
is always true for a crop anchored at the top-left corner, so the crop is
dropped and SvgImageProcessor delivers the original file.
Possible fix: compare against the original file’s dimensions instead of the
incoming (crop) dimensions, or skip this reset when the image is cropped.
Reviews 1
History 01
-
Gerrit Code Review pushed patch set 1 for main to change 97669 status
NewUnder Review <span data-processor="relativetime" data-value="2026-11-15T07:50:38+00:00" > 11/15/26, 07:50 </span>