#106094Exception in ImageProcessingInstructions if calculated maxWidth is float
Description
To reproduce:
Add a svg image with eg. 400 × 400 px (example image attached) as page thumbnail (via page properties using EXT:bootstrap_package). Add a menu content element “cards from subpages” to another page and select the parent page of the previous added page with the svg page thumbnail.
Open the page with the menu and you will get the following exception:
```
TYPO3\CMS\Core\Imaging\ImageProcessingInstructions::__construct(): Argument #1 ($width) must be of type int, float given, called in /var/www/html/vendor/typo3/cms-core/Classes/Imaging/ImageProcessingInstructions.php on line 231
```
The cause is a missing int cast at the returned width and height values of the static method ImageProcessingInstructions::fromCropScaleValues.
This problem can easily fixed by changing line 231-235 from this:
```
return new self(
width: $width,
height: $height,
cropArea: $cropArea,
);
```
to this:
```
return new self(
width: (int)$width,
height: (int)$height,
cropArea: $cropArea,
);
```
Reviews 4
- main 88522[BUGFIX] Add missing integer casting to ImageProcessing minHeight case
- 13.4 88523[BUGFIX] Add missing integer casting to ImageProcessing minHeight case
- 13.4 88238[BUGFIX] Fix failing image generation for width/height 0 thumbnails
- main 88206[BUGFIX] Fix failing image generation for width/height 0 thumbnails
Related issues 1
Files 2
History 1115
-
Garvin Hicking commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-02-13T19:10:59+00:00" > 02/13/25, 19:10 </span> -
Alexander Grein commented <span data-processor="relativetime" data-value="2025-02-14T10:16:48+00:00" > 02/14/25, 10:16 </span>
No, they don’t have all int casts.
Take eg. a look at line 181:$width = $options['maxWidth'];and line 187:
$height = $options['maxHeight'];and line 194:
$width = $options['minWidth'];and line 200:
$height = $options['minHeight'];In all cases, there is no int-cast afterwards, unless their values are “0” or $GLOBALS[‘TYPO3_CONF_VARS’][‘GFX’][‘processor_allowUpscaling’] == true and the width or height is larger than the cropArea width or height.
This is by far not always the case. -
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-02-14T10:44:48+00:00" > 02/14/25, 10:44 </span>
Yes, we would need to check if maybe bootstrap_package passes these options as floats, hence asking for the full stacktrace to see where they come from. Ideally we shouldnt fix a symtpom but a cause.
-
Alexander Grein commented <span data-processor="relativetime" data-value="2025-02-14T14:47:07+00:00" > 02/14/25, 14:47 </span>
Line 120: public static function fromCropScaleValues(int $incomingWidth, int $incomingHeight, int|string $width, int|string $height, array $options): self
This method is a public (static) not internal marked method, where the $options attribute has only to be an array.
Why should we search for the cause outside?
At the beginning of this method, there is a call to streamlineOptions. Maybe this would be a good place to make sure the critical options become integers if set?
This method (streamlineOptions) has this doc comment:
/** * @return array{ * maxWidth?: int, * maxHeight?: int, * minWidth?: int, * minHeight?: int, * crop?: Area, * } */But there is no int casting anywhere inside.
-
Alexander Grein changed attached TYPO3 Exception.html <span data-processor="relativetime" data-value="2025-02-14T15:07:32+00:00" > 02/14/25, 15:07 </span>
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-02-14T15:25:31+00:00" > 02/14/25, 15:25 </span>
Let’s investigate with the stack trace and where it comes from, thank you.
Of course you’re free to propose any patch you deem fit, but I personally always want to know where an issue arises from.Also, please let’s be constructive and appreciative to each other, I feel like I need to defend myself when all I want is to help.
-
Alexander Grein commented <span data-processor="relativetime" data-value="2025-02-14T18:05:22+00:00" > 02/14/25, 18:05 </span>
I like to do that too. I’m sorry if you got a different feeling.
I was just a bit annoyed, because I already created a patch for the site where I discovered this problem and I had to revert it first.
After doing this, I first thought the problem was magically gone, but after clearing the processed images cache it pops up again.
Next problem was the huge stack trace, where I had no idea how to add it to this tracker.Another thought that just popped into my head:
Since the private method “streamlineOptions” is only used once and the “fromCropScaleValues” method needs integer values in the end, the proposed solution seemed the most efficient to me.Maybe also interesting:
The svg image (attached) that creates the problem has a width of 400. The output of the bootstrap_package content element “cards from subpages” is used in the main column of the “2 columns layout with left side sub navigation”. The settings inside this content element are alignment left with 4 columns. -
Gerrit Code Review pushed patch set 4 for main to change 88206 status
Needs FeedbackUnder Review <span data-processor="relativetime" data-value="2025-02-15T10:18:11+00:00" > 02/15/25, 10:18 </span> -
Gerrit Code Review pushed patch set 5 for main to change 88206 <span data-processor="relativetime" data-value="2025-02-15T10:19:48+00:00" > 02/15/25, 10:19 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 88206 <span data-processor="relativetime" data-value="2025-02-15T12:07:07+00:00" > 02/15/25, 12:07 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 88238 <span data-processor="relativetime" data-value="2025-02-16T18:38:58+00:00" > 02/16/25, 18:38 </span>
-
Garvin Hicking commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-02-16T18:40:09+00:00" > 02/16/25, 18:40 </span>Applied in changeset commit:5b3efef806e0834dcaaeb25f2a1ddb951b1c1bfe.
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-02-18T12:06:50+00:00" > 02/18/25, 12:06 </span>
Hi Alexander,
you may have seen the patch got merged more quickly than I thought. I did rework the patch to add (int) casting like you proposed. Maybe you could check it out and see if that works out for you this way?
Regards,
Garvin -
Garvin Hicking changed Precedes #106329 <span data-processor="relativetime" data-value="2025-03-07T08:06:24+00:00" > 03/07/25, 08:06 </span>
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-08-12T14:35:42+00:00" > 08/12/25, 14:35 </span>
Hi!
Due to another issue I looked at this today. Actually, all of the places already have (int) casts in place for calculation of width and height, so I wonder where/how exactly a float is introduced.
I could only see that happenin in case an option like “maxWidth”/“minWidth” or “maxHeight”/“minWidth” would be specified with a float value.
Could you present the whole stack trace please?
Regards,
Garvin