80617[FEATURE] Crop SVG images natively
Commit message
Review
-
Code review CR +2 Done
- Benjamin Franzke +2
- Benni Mack +1
-
Verified V +2 Done
- Benjamin Franzke +2
- Benni Mack +1
- core-ci +1 CI
Issues 1
Files 16
- typo3/sysext/core/Classes/Imaging/SvgManipulation.php2new+196 −0
- typo3/sysext/core/Classes/Resource/Processing/ImageCropScaleMaskTask.php+1 −3
- typo3/sysext/core/Classes/Resource/Processing/ImagePreviewTask.php+1 −3
- typo3/sysext/core/Classes/Resource/Processing/LocalImageProcessor.php+3 −5
- typo3/sysext/core/Classes/Resource/Processing/SvgImageProcessor.php40+124 −8
- typo3/sysext/core/Configuration/DefaultConfiguration.php+1 −0
- typo3/sysext/core/Documentation/Changelog/13.1/Features-93942-CropSVGImagesNatively.rstnew+52 −0
- typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/ImageViewHelperTest1.svgnew+7 −0
- typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/ImageViewHelperTest2.svgnew+13 −0
- typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/ImageViewHelperTest3.svgnew+7 −0
- typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/ImageViewHelperTest4.svgnew+7 −0
- typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/ImageViewHelperTest5.svgnew+7 −0
- typo3/sysext/fluid/Tests/Functional/Fixtures/crops.csvnew+29 −0
- typo3/sysext/fluid/Tests/Functional/ViewHelpers/SvgImageViewHelperTest.phpnew+540 −0
- typo3/sysext/frontend/Tests/Functional/Rendering/Fixtures/SvgImageRenderingTest.typoscriptnew+175 −0
- typo3/sysext/frontend/Tests/Functional/Rendering/SvgImageRenderingTest.phpnew+182 −0
Review log 115170
Show 98145 earlier messages
-
Garvin Hicking uploaded patch set 1 08/22/23, 13:00
-
core-ci voted on patch set 1 V -1 08/22/23, 13:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45679
-
Garvin Hicking commented on patch set 1 08/22/23, 13:26
OK, I see PHPstan errors on the build pipeline, will address those. -
Garvin Hicking uploaded patch set 2
V -108/22/23, 14:31 -
core-ci voted on patch set 2 V +1 08/22/23, 14:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45689
-
Garvin Hicking commented on patch set 2 08/23/23, 10:04
To clarify on this patch: This is more a "proof of concept". It is meant to kickstart discussion about how to handle the "non-cropping" of SVGs. A current workaround for us is to override ViewHelpers and simply set the argument `fileExtension` to `svg`. Since this is not a valid output format, the whole core processing logic of converting svg to png/jpg will be circumvented. But overriding a viewhelper remains a workaround. The TYPO3 core should be able to let integrators decide whether SVGs shall be converted to bitmaps or shown as is. The main drawback of this patch as it currently is: It appends a "#svgView(viewBox(...)))" parametrization to the target URI. This is escaped however, and needs to be unsecaped for further processing. Also, the changes needed for the patch are currently a lot, and maybe there is a denser approach to this. If anyone at some point is open for getting this solved, I am open to discussion and creating other PoC variants of this. Let me know - I could also participate in a codesprint about this... :-) -
Garvin Hicking uploaded patch set 3
V +108/23/23, 17:28 -
Garvin Hicking commented on patch set 3 08/23/23, 17:31
I have tried a second approach to this, which doesn't make vector to bitmap processing optional (thanks to input from @lolli42). Testing instructions: * Ensure that you create a test page and insert a standard content element using a SVG image that is rendered through fluid * Make sure you clear your processed files through the TYPO3 backend maintenance panel (existing processed, rasterized files might be cached otherwise!) * Check the HTML source, search for a '#svgView' piece, that should be inserted. * Let me know your thoughts on this or different approaches 😊 -
core-ci voted on patch set 3 V -1 08/23/23, 17:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45763
-
Garvin Hicking uploaded patch set 4
V -108/23/23, 17:49 -
core-ci voted on patch set 4 V +1 08/23/23, 17:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45764
-
Simon Praetorius commented on patch set 4 CR -1 08/25/23, 17:05
I think that this could be implemented in a cleaner way, either by registering a separate processor for SVG files (see $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors'] and TYPO3\CMS\Core\Resource\Processing\ProcessorRegistry) or by using a "BeforeFileProcessingEvent". This would get rid of the "is it a SVG" check in the LocalCropScaleMaskHelper that otherwise uses im/gm for image processing. -
Garvin Hicking commented on patch set 4 08/25/23, 17:09
Reply
You mean the core on its own should use an event to "fix" this behaviour? I'd have to dig into using FAL processors, I don't have knowledge about this yet on how to proceed with that approach. (Personally, firing events at this or using a full processor when a simple bypass is all that's needed might require more resources and be harder to maintain...? But I value your input on this, I'll check out how much overhead that really would be) -
Simon Praetorius commented on patch set 4 08/25/23, 17:15
Reply
You're right, the event probably doesn't make sense. 😊 I'd guess that the SVG processor would be pretty lightweight compared to the existing processor. It can also be tested separately and could be extended to cover other SVG-specific adjustments in the future. -
Garvin Hicking commented on patch set 4 08/25/23, 17:18
Reply
Oh boy. Why did I just now find out about these 'fal' processors? I see there's already a SvgImageProcessor. It bails when 'crop' is defined. So I actually need to "just" implement the croping in that processor I think. Wow, I feel stupid. I'll be processing ;) this and report back with a new approach. Your input was invaluable to me, thank you! -
Garvin Hicking commented on patch set 4 08/25/23, 17:21
Reply
(I think I'll possibly add a new Processor like SvgImageCropProcessor, so if actually someone ever wants to not Crop SVGs, they could just remove the SvgImageCropProcessor from the configuration...) -
Garvin Hicking uploaded patch set 5
CR -1V +108/29/23, 09:21 -
core-ci voted on patch set 5 V -1 08/29/23, 09:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45961
-
Garvin Hicking uploaded patch set 6
V -108/29/23, 10:00 -
core-ci voted on patch set 6 V +1 08/29/23, 10:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45966
-
Garvin Hicking uploaded patch set 7
V +108/29/23, 12:37 -
Garvin Hicking uploaded patch set 8 08/29/23, 12:41
-
Garvin Hicking uploaded patch set 9 08/29/23, 12:42
-
Garvin Hicking commented on patch set 9 V +1 CR +1 08/29/23, 12:45
Reply
DoneReply
DoneSorry for the patchset flood. There was a lot to address, thanks to Simon. I hope this leaves us now to discuss, whether a distinct processor is acceptable. If this can find acceptance, I'll be happy to work on additional tests. -
core-ci voted on patch set 7 V -1 08/29/23, 12:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45978
-
core-ci voted on patch set 8 V -1 08/29/23, 12:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45979
-
core-ci voted on patch set 9 V -1 08/29/23, 12:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45980
-
Andreas Kienast commented on patch set 9 08/29/23, 12:53
General remark: please do not vote your own patch, unless somebody else reworked it completely. Also, if it's a breaking change, please prepend your commit message with `[!!!]`, e.g `[!!!][FEATURE] Prevent SVG...` -
core-ci voted on patch set 9 V +1 08/29/23, 12:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45980
-
Garvin Hicking commented on patch set 9 V 0 CR 0 08/29/23, 12:58
Reply
Ah ok, I'm sorry. I'm not familiar enough with this system yet, so this helps. I thought that I could use this to indicate that a patch works on my system, my fault. I'll change the `[!!!]` prefix later, good point. It seems the CI build process is currently wonky, so I don't want to add to the queue and do that later on when additional feedback is provided (and leave this unresolved so long). -
Garvin Hicking updated the commit message in patch set 10
V +108/30/23, 08:30 -
core-ci voted on patch set 10 V +1 08/30/23, 08:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46020
-
Benni Mack commented on patch set 10 09/18/23, 21:09
clever solution. I like it. Will do some cleanups in this area currently, but will get back to this one soon -
Garvin Hicking uploaded patch set 11
V +109/19/23, 07:13 -
Garvin Hicking rebased onto patch set 12 09/19/23, 07:15
-
Garvin Hicking commented on patch set 12 09/19/23, 07:17
Rebased patch to catch up with https://review.typo3.org/c/Packages/TYPO3.CMS/+/81073 -
core-ci voted on patch set 11 V +1 09/19/23, 07:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46731
-
core-ci voted on patch set 12 V +1 09/19/23, 07:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46732
-
Benni Mack commented on patch set 12 09/20/23, 22:25
I suggest: - let's move all in one SvgProcessor to ease the complexity, - this way we can reduce the checks in the AbstractImageTask by allowing gif,png,jpeg,jpg,svg as well -
Garvin Hicking commented on patch set 12 09/21/23, 05:22
Reply
I could happily rebuild that. We would lose the flexibility to offer integrators NOT cropping SVGs then, so if anyone wants to actually rasterize cropped SVGs (for whatever reasons; not exposing raw vectors to the public, preventing security issues of SVGS, ...) -- they would then need to create their own falprocessor. Would be fine with me, just making sure about the implications. -
Garvin Hicking commented on patch set 12 09/21/23, 07:03
Reply
I think integrators might be able to live with specifying `fileExtension` as a parameter to i.e. f:image to deal with this kind of customization. I'll rework this and also think about testing and a demo extension to reproduce the extension, please hang on. :-) -
Benni Mack uploaded patch set 13
V +109/21/23, 11:13 -
Benni Mack commented on patch set 13 09/21/23, 11:13
Reply
Done -
Garvin Hicking commented on patch set 13 09/21/23, 11:22
Looking good to me from a "table read" perspective. I'll want to test this with an extension I'm trying to build catching different variations of it. Also want to enhance the commit message with a (working) fluid example on how to use a f:image viewhelper to force pixel conversion. It may take me until next week though to test this. If you need/want to proceed adding this before, don't let me be a holdup. Also not 100% sure on whether `applyCropping()` is a utility method that should be available in another Service and shouldn't be SVG-specific. -
core-ci voted on patch set 13 V +1 09/21/23, 11:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47006
-
Benni Mack commented on patch set 13 CR -1 09/21/23, 11:51
we need to document the behavior of this processingUrl, this took me most of the time, because this was originally built for deferred images, and is automatically emptied when the file is available. The combination of ->setUsesOriginalFile() and ->updateProcessUrl() needs some more fine-tuning. -
Garvin Hicking uploaded patch set 14
CR -1V +109/21/23, 12:20 -
core-ci voted on patch set 14 V +1 09/21/23, 12:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47010
-
Garvin Hicking uploaded patch set 15
V +109/25/23, 13:11 -
core-ci voted on patch set 15 V +1 09/25/23, 13:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47154
-
Oliver Klee commented on patch set 15 09/25/23, 13:20
SvgImageProcessor.php:111For the benefit of the human reader (to reduce cognitive load when reading this code), I suggest switching the condition to include the class: ```php if ($svg instanceof SimpleXMLElement) { ``` -
Oliver Klee wrote 10/08/23, 13:23
Removed cc Oliver Klee. -
Garvin Hicking commented on patch set 15 10/11/23, 07:23
Just an update on this, because I only updated it in the ticket and not here: The current patch set 15 seems to work well with a content image crop (FAL-based). It also works when using i.e. a flexform or a custom content element and <f:image> with an image=... FAL reference. However, it does not work when using a <f:image src="..."> definition (non-FAL). Probably because $task->getTargetFile()->updateProcessingUrl(...) is only used for file references with attached crops, but not locally sourced static files? Sadly I don't know where to dig in the reorganized code to make it work for this. The SVG is passed through, but the '#svgBox...' URI fragment is missing. This may actually even be related to changes that seem to deprecate allowing passing non-FAL assets to <f:image> viewHelpers, which is IMO a very important thing that must work (see https://review.typo3.org/c/Packages/TYPO3.CMS/+/81319 for more) Bonus task: Currently it seems using <f:image ... fileExtension="png"> does NOT enforce rendering an SVG through a PNG process, probably because of that same non-FAL problem. I've created a simple extension showcasing the issue (requires the applied patch ofc): https://github.com/garvinhicking/gh_svg_crop -
Garvin Hicking uploaded patch set 16
V +110/16/23, 13:50 -
core-ci voted on patch set 16 V +1 10/16/23, 13:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47824
-
Garvin Hicking commented on patch set 16 10/16/23, 14:04
(Some improvements, however non-FAL based image conversion/cropping is still broken via f:image, as well as forcing PNG conversion from an SVG via f:image)SvgImageProcessor.php:111ReplyThanks, included that (with \SimpleXmlElement) -
Benjamin Franzke commented on patch set 16 V -1 10/30/23, 16:34
Sorry, as much as I'd like this BUGFIX to have, I fear this doesn't work properly for images that are sized via CSS `width` or `height` property, as `#svgView` does only allow to set the viewBox, but doesn't keep infered width/height attributes. I did some testing, and whenever I set `width` or `height` via css the "cropping" (seen in example 1) is lost, because the correct width/height ratio is only available on the HTML tag attributes: https://bnf.dev/~ben/uploads/628dd/svgView-css-width-height.png Also the behavior differes between SVG's that contain `width` and `height` attributes (on the files `<svg>` tag) an those that do not. I think we need to find another way for this issue: We should actually create a proper SVG processor that: * Read's in SVGs * sanitizes via svg-sanitizer * parses viewBox and width/height attributes * wraps the sanitized SVG as-is as a child-svg into an outer `<svg width="…" height="…" viewBox="…">` tag This way the generated SVGs are fully stylable width `width` and `height` and behave as their "pixel"-counterparts. @Garvin, would you like to try doing that? -
Garvin Hicking commented on patch set 16 10/30/23, 17:33
Reply
I'm quite frustrated with this one here. Current approach did work for many cases but has some quirks, and I wasn't able to work it out on my own. I like your alternate approach you offered. Even though it has more "overhead", it is probably easier in implementation. I'd need someone to bounce approaches against though, because I think I'm a bit over my head in this. I'm much willing to do the legwork here if I could get someone to be a sparring partner (maybe not even a "mentor" level is needed). Would you be able to be "that guy" or anyone else reading this? I'll probably be around for the Codesprint in November, maybe someone would want to look over my shoulder on this... Thanks so much for your constructive criticism (the other's, too!) so far, much appreciated! -
Garvin Hicking commented on patch set 16 10/30/23, 17:35
Reply
(oh, one more thing - I agree this is no longer a bugfix, since it also now depends on the v13 FAL work to be applicable) -
Benjamin Franzke commented on patch set 16 11/27/23, 14:51
Reply
Sorry, I didn't noticed your answer. Feel free to ask me anything on slack, I'm sure we/you can get that done. -
Garvin Hicking commented on patch set 16 11/27/23, 15:24
Reply
Thanks! I'll try to find the willpower (again) for this and try a proof-of-concept with which we hopefully can go on. Due to deadline-projects of mine it may take me a few weeks though! -
Garvin Hicking commented on patch set 16 11/30/23, 11:52
Just to document an update here. There are a couple of quirks that make using the `#svgView(viewBox())` URI fragement not usable within reasons. The main issue being that crops will be scaled/skewed, if the resulting SVG image is scaled via CSS/HTML operations. That can only be remedied by actually creating processed files where the proper viewBox and dimensions are "baked in". These are my findings: * We need "baked-in" viewBoxes. Per viewBox-crop, one processed file will need to be generated. Just like with pixel images. * We want to use IMG tags, because CSS styling is easier and less-breaking than requiring to style a SVG tag (which would prevent one layer of processed-file wrapping). Also, only with the img-way (using a wrapped processe file) we can use processed files as background images (i.e. make f:uri.image work with SVGs, too). * The processed file should create a SVG wrapper around the original input file. * We can NOT use the inline `<image>/<use>` reference to the original image, because browser's security models will not resolve it. The same reason prevents using `src:data...`. * The original input file needs manipulation to enforce receiving width/height attributes, because otherwise the cropping will not be relative to the image dimensions. * More specifically: The actual processing logic will need to ensure that width/height/viewbox attributes are properly set on both inner ("original file") and outer SVG ("crop/scale variant"). To allow proper browser resizing / responsivity on the `<img>` tag, the logic should be applied for both cropping and scale (without crop). A demo showing the evolution and issues of the alternatives can be checked out here https://gist.github.com/garvinhicking/257d4920da4da0c0e1c3fba3a0b313c9 Will check further with all of the Benjamins available to me. ;-) -
Garvin Hicking uploaded patch set 17
V +112/01/23, 20:59Huge rework dropping URI fragments creating processed files -
Garvin Hicking commented on patch set 17 12/01/23, 21:02
I've spent a LOT of time on this now to get reworked to my "proof-of-concept" way of processing files, since the URI fragement thing proved a one-way-street. I've tested this with a simple dev environment here: https://github.com/garvinhicking/typo3-core-bugreproduce/tree/issue_80617 specifically: https://github.com/garvinhicking/typo3-core-bugreproduce/blob/issue_80617/packages/gh_svg_crop/Resources/Private/Templates/List.html This is still a bit flakey and needs refactoring, but I'm now holding my horses to get some feedback on both proof-of-concept and this current approach. Fingers crossed. -
core-ci voted on patch set 17 V -1 12/01/23, 21:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50222
-
Garvin Hicking uploaded patch set 18
V -112/01/23, 21:10Removed accidental commit to cleanup task removed ViewHelper because this did not work as intended -
Garvin Hicking uploaded patch set 19 12/01/23, 21:12
Revert once more with feeling -
core-ci voted on patch set 18 V -1 12/01/23, 21:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50223
-
core-ci voted on patch set 19 V -1 12/01/23, 21:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50224
-
Garvin Hicking uploaded patch set 20
V -112/01/23, 21:20CGL -
core-ci voted on patch set 20 V +1 12/01/23, 21:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50225
-
Garvin Hicking uploaded patch set 21
V +112/19/23, 15:21Rebased fixed conflicts -
core-ci voted on patch set 21 V +1 12/19/23, 15:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50819
-
Garvin Hicking uploaded patch set 22
V +112/19/23, 22:58Add tests -
core-ci voted on patch set 22 V -1 12/19/23, 23:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50825
-
Garvin Hicking uploaded patch set 23
V -112/19/23, 23:09Fix ACL perms on SVGs and remove obsolete array -
core-ci voted on patch set 23 V +1 12/19/23, 23:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50828
-
Simon Praetorius commented on patch set 23 12/21/23, 13:10
SvgImageProcessor.php:104Maybe use null as fallback values here and apply real fallback values later when calling applyCroppingToProcessedFile()? That way the processor would behave similar when the json is invalid and when the comma-separated format is invalid/incomplete. Also, I'm not sure if 1 would be a better fallback for height/width?SvgImageProcessor.php:116Maybe a short example of the new svg structure could be added here as a comment.SvgImageProcessor.php:123Maybe a better variable name would be something like "wrapperSvg" or "croppedSvg"? I found the code hard to understand because of the two filesSvgImageProcessor.php:137This would leak the TYPO3 version to a publicly available file. I don't think that this is wise and necessary.SvgImageProcessor.php:163Why are the original dimensions used here? If that's correct, it should be explained in the commentSvgImageProcessor.php:173If it exists, take info from that file and mark task as doneSvgImageProcessor.php:215I would suggest "determineSvgDimensions" as an alternative nameSvgImageProcessor.php:229Check for existence of 2 and 3. If the viewbox is invalid/incomplete, it's probably best to check for width/height next?SvgImageProcessor.php:235I would check if the width/height value is a valid number, for example with is_numeric(). If it isn't, fallback to default dimension. -
Garvin Hicking uploaded patch set 24
V +112/21/23, 22:23Added more tests and fixtures -
core-ci voted on patch set 24 V -1 12/21/23, 22:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50879
-
Garvin Hicking uploaded patch set 25
V -112/21/23, 22:47Moved expecation check -
Garvin Hicking commented on patch set 25 12/21/23, 22:51
@Simon - thanks for your initial review. That helped to refactor a few shortcomings and I hope to have adressed these properly. I'll still need to perform more tests on crop via "c" and "m" parameters, ensure it all works with (max|min)(Width|Height) set/unset, and add FAL-UID tests for the typoscript-based tests. The other crop tests now got a massive boost with 144 variations checked now. This is not really great to test, this "crop" syntax with sometimes relative 0..1 values or absolute X/Y coordinates and their juggling back and forth.SvgImageProcessor.php:104ReplyNote sure about this one yet, need to think on it and add more tests.SvgImageProcessor.php:116ReplyDoneSvgImageProcessor.php:123ReplyDoneSvgImageProcessor.php:137ReplyDoneSvgImageProcessor.php:163ReplyDoneSvgImageProcessor.php:173ReplyI copy+pasted this from LocalImageProcessor. The wording was a bit odd. I've adjusted it in both places now.SvgImageProcessor.php:215ReplyDoneSvgImageProcessor.php:229ReplyDoneSvgImageProcessor.php:235ReplyDone -
core-ci voted on patch set 25 V +1 12/21/23, 22:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50884
-
Garvin Hicking uploaded patch set 26
V +112/23/23, 10:45Switch SVG assets for smaller variants -
core-ci voted on patch set 26 V -1 12/23/23, 10:52 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50925
-
Garvin Hicking uploaded patch set 27
V -112/23/23, 11:03Fix unneeded fixture of pages -
core-ci voted on patch set 27 V +1 12/23/23, 11:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50926
-
Garvin Hicking uploaded patch set 28
V +112/23/23, 18:25XML bugfix and optimize testing assets -
core-ci voted on patch set 28 V +1 12/23/23, 18:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50941
-
Garvin Hicking uploaded patch set 29
V +112/23/23, 18:54Add safety typechecks for crop input conversion -
Garvin Hicking commented on patch set 29 12/23/23, 18:54
SvgImageProcessor.php:104ReplyOK, I've altered this place to better handle fallbacks. I cannot use "null" due to later typehinting, where I want to expect integers. A malformed "crop" string could happen when passed to the imgResource typoscript place. ViewHelpers actually do not allow a commaseparated string, it only works with arrays (raw or json_encoded). Thanks for pointing me to this, I also now fall back to the image's width/height, if a malformed input cannot resolve proper newWidth/newHeights. -
core-ci voted on patch set 29 V +1 12/23/23, 18:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50942
-
Anja Leichsenring commented on patch set 29 CR +1 V +1 01/03/24, 07:08
that works like a charm. Thank you very much for taking care of this annoyance. -
Benjamin Franzke commented on patch set 29 CR -1 01/03/24, 09:46
Thank you, looks good regarding the general approach: As we already discussed last year via slack (so this is basically for other reviewers): neither data-uri's (browsers didn't load them) nor references via <image> (not working for protected storages), nor svg fragments (css issues) where options, so yea, while this approach has the slight drawback, that we have to copy the entire SVG, it's the only compatible way for solving this we could find. So I think we should get this done. Some early remarks regarding the implementation below – I will test this soon, but will leave this feedback for now already. still -1 for now, as I'm certain `width`/`height` has to prefered over `viewBox` for initial/original width/height calculation.SvgImageProcessor.php:180I think preserveAspectRatio should be "preserved" => copy from inner svgSvgImageProcessor.php:182This seems unneeded, as the dimensions are available from the inner element. This looks a bit like a (useful) debugging helper, but nothing we'd want in production.SvgImageProcessor.php:185Not sure I like this: * Information Disclosure(?) * Do you mean to use this for future migrations? we do not have the raw input data available anyway, so I don't think we can autoupdate anyway.SvgImageProcessor.php:232This looks wrong, the initial width/height is the `width` and `height` attribute. We should only fallback to deviate from viewBox in case we encounter an SVG without explicit `width`/`height` attributes. I'll look into that, but for now this is a blocker IMO.SvgImageProcessor.php:273Looks good (because yea, wouldn't work without explicit inner width/height) definition in general. I just wonder what to do in case only one of the attributes is provided. Leaving this open in order to test such a case: We had cases where `<svg xmlns="http://www.w3.org/2000/svg" height="135">…</svg>` was used to be able to only vertically scale an SVG. – sure we can't "properly" crop those, just want to test what happens to that wrapper, in order to avoid problematic bugs) -
Garvin Hicking commented on patch set 29 01/03/24, 10:39
Thanks Benjamin for having a look. Just some quick feedback on one issue. Please feel free to modify this patch with changes. You probably are right about the width/height usage and its preference.SvgImageProcessor.php:185ReplyYes I changed that from the main TYPO3 version after Simons remark. I do think we might need migrations and need some kind of information for it. We would only bump this version when needed, so a direct relation might not be needed? The original data is wrapped, so we could use it? Then again, we could also rebuild... -
Garvin Hicking uploaded patch set 30
CR +1V +101/08/24, 09:19Rework width and height logic brush up -
Garvin Hicking commented on patch set 30 01/08/24, 09:20
Adressed Benjamins comments, reworked width/height logic and removed some unneeded attributes. Crossing my fingers we could get this wrapped up for 13.0.SvgImageProcessor.php:180ReplyGood idea. Actually I can now remove a fixed default setting ("xMidYMid meet" is a default already).SvgImageProcessor.php:182ReplyAgreed. Added that as a comment, so it can be easily used and there's a pointer for people looking into it in the future.SvgImageProcessor.php:185ReplyAfter some more thought, I agree and removed this. Thanks for addressing it. We probably should just re-create all cropped SVG assets (could be deduced from sys_file_processedfile) in case of formatting changes. Just deleting the processed files and entries would then use new code, if added.SvgImageProcessor.php:232ReplyYes, you are right. viewBox lead me onto a wrong path because it appeared as if pixel sizes were used there, while width/height COULD actually have "150cm" or "50%" values. I checked this with uploading SVGs into TYPO3v12 using a `width='50%'` or `width='23mm'` and there the image information gets saved as `50px`/`23px`, so the unit is just dropped. This kind of makes sense, because without DPI output information on processing, a real calculation can't be made, and a unit of `1` seems to make sense. I adapted the code to account for this, it now uses: * Use width/height, if numeric values (pixel) * else: if viewBox width/height is set, use that. * else: remove the unit, use width/height * else: no width/height, use viewBox * else: no width/height, no viewBox, use defaultDimensions (64x64) - but such an SVG will be quite brokenSvgImageProcessor.php:273ReplyCan you provide an actual SVG of how the input would then look like, especially how/if a viewBox attribute was specified? I created a simple SVG image with only `height` attribute set, and I can't even upload such a SVG file to TYPO3v12 (it shows up as broken, has no dimensions set). -
core-ci voted on patch set 30 V +1 01/08/24, 09:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51206
-
Garvin Hicking rebased onto patch set 31
V +101/25/24, 19:41 -
core-ci voted on patch set 31 V +1 01/25/24, 19:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52204
-
Benni Mack commented on patch set 31 01/25/24, 22:53
ContentObjectRenderer.php:3725this can be removed, as I've done this a 2 lines further below -
Garvin Hicking uploaded patch set 32
V +101/26/24, 06:24Remove double floatval cast -
Garvin Hicking commented on patch set 32 01/26/24, 06:25
ContentObjectRenderer.php:3725ReplyThanks. Wonder if this got introduced with the rebase, can't remember seeing this. -
core-ci voted on patch set 32 V +1 01/26/24, 06:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52212
-
Garvin Hicking rebased onto patch set 33
V +101/29/24, 13:56 -
core-ci voted on patch set 33 V +1 01/29/24, 14:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52419
-
Benni Mack commented on patch set 33 02/05/24, 07:33
SvgImageProcessor.php:215should we remove the local file §temporaryFilename again? -
Garvin Hicking commented on patch set 33 02/05/24, 07:54
SvgImageProcessor.php:215ReplyThe local processed file is what gets emitted to the browser, so we need it (to prevent re-cropping the samw file time and again), or did I misunderstand you? (will address the merge conflicts later today, should be easy because Simons patch implemented part of my tests too) -
Garvin Hicking uploaded patch set 34
V +102/05/24, 08:49Rebase -
core-ci voted on patch set 34 V +1 02/05/24, 09:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/52704
-
Garvin Hicking uploaded patch set 35
V +102/26/24, 08:40Adapt to phpunit attributes -
Garvin Hicking uploaded patch set 36 02/26/24, 08:45
Revert accidental commits from rector run -
core-ci voted on patch set 35 V -1 02/26/24, 08:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53584
-
core-ci voted on patch set 36 V +1 02/26/24, 08:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53586
-
Benni Mack uploaded patch set 37
V +103/05/24, 21:14 -
core-ci voted on patch set 37 V -1 03/05/24, 21:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53984
-
Benjamin Franzke uploaded patch set 38
V -103/05/24, 21:55 -
Benjamin Franzke commented on patch set 38 03/05/24, 21:55
SvgImageProcessor.php:114I'd like to understand when this case happens (that we receive crop data that does not define a width/height, only x/y) (This smells like this should be an exception instead, but I'll need to check other processors) The respective code in typo3/sysext/core/Classes/Imaging/ImageProcessingInstructions.php::streamlineOptions seems to assume that the width/height has to be set in the crop configuration. In general I wonder whether we can reuse the code for parsing the `crop`-string.SvgImageProcessor.php:116Can you point me to the place where te string representation is parsed for other image processors? (well, or is that passed-through to imagemagick? (in that case I'd add a comment, that we're preg-parsing the imagemgick syntax in here) -
core-ci voted on patch set 38 V -1 03/05/24, 22:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53987
-
Benjamin Franzke commented on patch set 38 03/05/24, 22:06
SvgImageProcessor.php:215ReplyThe processed file is placed into the FAL storaged processed folder. For fileadmin that would be `/fileadmin/_processed_/`. We're still fine here, since updateWithLocalFile call FAL addFile which renames the input file. => That means the file is moved from typo3temp to `/fileadmin/_processed_/`. Therefore I'm resolving hereSvgImageProcessor.php:273ReplySimply removing the width attribute. But that is really a corner case and the code is handling this properly. All good. -
Benjamin Franzke uploaded patch set 39
CR -1V +103/05/24, 22:28Revert to patchset 37 -
core-ci voted on patch set 39 V -1 03/05/24, 22:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53989
-
Benjamin Franzke uploaded patch set 40
V -103/05/24, 22:39 -
core-ci voted on patch set 40 V +1 03/05/24, 22:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53991
-
Oli Bartsch wrote 03/05/24, 23:10
Removed cc Oli Bartsch. -
Benjamin Franzke uploaded patch set 41
V +103/05/24, 23:50 -
Benjamin Franzke commented on patch set 41 03/05/24, 23:50
SvgImageProcessor.php:114ReplyRemoved and streamlined into ParseCropTrait.SvgImageProcessor.php:116ReplySee above, moved into ParseCropTrait -
core-ci voted on patch set 41 V -1 03/05/24, 23:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53993
-
Benjamin Franzke uploaded patch set 42
CR +1V +103/06/24, 05:24 -
core-ci voted on patch set 42 V +1 03/06/24, 05:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53997
-
Garvin Hicking uploaded patch set 43
CR +1V +103/06/24, 11:30Consider maxWidth and maxHeight -
core-ci voted on patch set 43 V -1 03/06/24, 11:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54025
-
Garvin Hicking uploaded patch set 44
V -103/06/24, 11:42Missed a rounding entry in commit -
core-ci voted on patch set 44 V +1 03/06/24, 11:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54027
-
Garvin Hicking commented on patch set 44 03/06/24, 12:00
As discussed with Benjamin Franzke, there was a problem in the backend. The FAL picker (IRRE assignment in a content element) used image maxWidth/maxHeight specifications. The current approach did not take that into account, because it was focussed at frontend integration, where a SVG asset is usually embedded with a fixed size (or inherent) and scaled via CSS. I've now addressed this via: * Passing along the imageDimension object to retrieve the calculated image size. `ImageProcessingInstructions::fromCropScaleValues()` does that, by way of `ImageDimension::fromProcessingTask()`. * That imageDimension object now fills width/height for both `targetFile::updateProperties()` as well as the wrapping `<svg>` container width/height attributes * Adjusted tests for that, and added a maxWidth test case, too. Adjusted commit message to drop the maxWidth note. * The tests revealed that the missing rounding of image dimension calculation don't account for the now created image dimensions (width/height calculation does the same `round()`, so it would mismatch if the crops were not rounded, too. That is in line with Benjamin's todo note, which is now removed. * Since this is not backportable anymore (within reason) we might want to declare it as a feature. Adjusted title, and added a ReST with it, that describes this very briefly. -
Benjamin Franzke commented on patch set 44 CR +1 V +1 03/06/24, 12:02
❤️ -
Marvin Buchmann voted on patch set 44 V +1 03/08/24, 09:11
-
Benjamin Franzke uploaded patch set 45
CR +1V +103/08/24, 10:41 -
core-ci voted on patch set 45 V -1 03/08/24, 10:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54232
-
Benjamin Franzke uploaded patch set 46
V -103/08/24, 18:26 -
core-ci voted on patch set 46 V -1 03/08/24, 18:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54297
-
Benjamin Franzke uploaded patch set 47
V -103/08/24, 19:09 -
Benjamin Franzke voted on patch set 47 CR +1 V +1 03/08/24, 19:10
-
core-ci voted on patch set 47 V -1 03/08/24, 19:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54304
-
Benjamin Franzke uploaded patch set 48
CR +1V +103/08/24, 19:24 -
Benjamin Franzke voted on patch set 48 CR +1 03/08/24, 19:24
-
core-ci voted on patch set 48 V -1 03/08/24, 19:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54305
-
Benjamin Franzke uploaded patch set 49
CR +1V +103/08/24, 19:43 -
core-ci voted on patch set 49 V -1 03/08/24, 19:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54307
-
Benjamin Franzke uploaded patch set 50
V -103/08/24, 21:06 -
core-ci voted on patch set 50 V +1 03/08/24, 21:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54310
-
Benjamin Franzke rebased onto patch set 51
V +103/11/24, 07:17 -
core-ci voted on patch set 51 V +1 03/11/24, 07:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54348
-
Garvin Hicking commented on patch set 51 03/11/24, 09:13
Thanks Benni & Benjamin for iterating on this again. Tried and works in all my test cases with all my test assets. -
Benni Mack uploaded patch set 52
V +103/11/24, 16:07 -
Benni Mack voted on patch set 52 CR +1 V +1 03/11/24, 16:08
-
Benni Mack uploaded patch set 53
CR +1V +103/11/24, 16:10 -
core-ci voted on patch set 52 V +1 03/11/24, 16:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54375
-
Benni Mack voted on patch set 53 CR +1 V +1 03/11/24, 16:13
-
core-ci voted on patch set 53 V +1 03/11/24, 16:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54376
-
Benni Mack uploaded patch set 54
CR +1V +103/11/24, 16:22 -
Benni Mack voted on patch set 54 CR +1 V +1 03/11/24, 16:22
-
Benjamin Franzke voted on patch set 54 CR +1 V +1 03/11/24, 16:24
-
core-ci voted on patch set 54 V +1 03/11/24, 16:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/54377
-
Benjamin Franzke voted on patch set 54 CR +2 V +2 03/11/24, 16:46
-
Benjamin Franzke merged patch set 55 03/11/24, 16:46
-
Oliver Hader commented on patch set 55 03/11/24, 17:44
SvgManipulation.php:60Depending on the file size and nested structure, it might be required to allow huge files - see * https://github.com/darylldoyle/svg-sanitizer/blob/master/src/Sanitizer.php#L229C84-L229C100 * https://www.php.net/manual/en/libxml.constants.php#constant.libxml-parsehuge -
Garvin Hicking commented on patch set 55 04/05/24, 13:17
SvgManipulation.php:60ReplyAcknowledged