[Bug] ImageGraph API doesn't adjust height/width when max dimension exceeded changing its ratio #22390
Open
4 tasks done
Labels
Potential Bug
Something that might be a bug, but needs validation and confirmation it can be reproduced.
triaged
What happened?
The current ImageGraph API renders images up to 2048px width/height.
Should the width or height exceed either value, then the value is limited to 2048pixel.
This can be ok behaviour.
However, given below URL:
https://demo.matomo.cloud/index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageUrls&token_auth=anonymous&period=day&date=2024-06-12,2024-07-11&filter_sort_column=nb_hits&column=nb_hits&columns=nb_hits&language=en&width=3100&height=1420&fontSize=32&showMetricTitle=0&aliasedGraph=1&legendAppendMetric=0&backgroundColor=efefef&gridColor=dcdcdc&colors=3450A3%2C43a047&legendFontSize=32&cacherand=400098&showMetricTitle=1&showLegend=1&legendAppendMetric=1
What happens is is that Matomo restricts the width 3100 to 2048px but keeps the height at 1420.
I would have expected that when Matomo restricts the width or height that it ensures the ratio of the image is kept.
This is not the case and thus the image looks funny in our native Android/iOS mobile app where we often request images in > 3000px wide or high. The images look stretched and not professional.
What should happen?
When restricting the max width or height, keep the ratio of the requested dimension.
Eg above requested was 3100x1420.
I would have expected dimensions to be roughly 2048x938px.
How can this be reproduced?
Open https://demo.matomo.cloud/index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageUrls&token_auth=anonymous&period=day&date=2024-06-12,2024-07-11&filter_sort_column=nb_hits&column=nb_hits&columns=nb_hits&language=en&width=3100&height=1420&fontSize=32&showMetricTitle=0&aliasedGraph=1&legendAppendMetric=0&backgroundColor=efefef&gridColor=dcdcdc&colors=3450A3%2C43a047&legendFontSize=32&cacherand=400098&showMetricTitle=1&showLegend=1&legendAppendMetric=1
Inspect width/height
Matomo version
5
PHP version
No response
Server operating system
No response
What browsers are you seeing the problem on?
No response
Computer operating system
No response
Relevant log output
No response
Validations
The text was updated successfully, but these errors were encountered: