Page MenuHomePhabricator

SVG images in preview render as PNG rather than SVGs
Open, Needs TriagePublic

Description

When I preview the page "Qajar Dynasty" on the page "Battle_of_Krtsanisi," by hovering over Qajar Iran the flag renders in low resolution.

Screenshot (472).png (900×1 px, 406 KB)

However, the actual file is not low-resolution at all.

Developer notes

This is an API problem.

The SVG is converted to a PNG
https://en.wikipedia.org/api/rest_v1/page/summary/Qajar_Iran

Ideally the API should be returning a SVG rather than a PNG, however this may be a limitation of PageImages or MediaWiki.

Event Timeline

Hi @Firestar464, thanks for taking the time to report this! For future reference, please use the bug report form instead, linked from the top. This does not seem to be about History_of_Russia but about https://en.wikipedia.org/wiki/Battle_of_Krtsanisi (please always include full links).

The image displayed in the page preview is https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/State_flag_of_Persia_%281907%E2%80%931933%29.svg/480px-State_flag_of_Persia_%281907%E2%80%931933%29.svg.png
Link: https://commons.wikimedia.org/wiki/File:State_flag_of_Persia_(1907%E2%80%931933).svg

This might be a duplicate of T268999: Show medium size (<320 wide, but >=250 high) images as well.

Jdlrobson subscribed.

Yeh I suspect this is a duplicate of that existing issue.

Jdlrobson renamed this task from Image rendering in low resolution in preview despite actual image not being low-resolution to SVG images in preview render as PNG rather than SVGs.Aug 2 2021, 7:21 PM
Jdlrobson updated the task description. (Show Details)

Historically there were issues "thumbnailing" SVGs -- the image size isn't the issue, it's the *file size*. In order to have an SVG thumbnail of (for example) a complicated map with millions of line segments, you need to subsample the image in a very different way than we do for bitmaps. So historically we "always" rendered PNGs when a thumbnail was requested of an SVG, in order to avoid DOS type attacks from large/complex SVGs.

I vaguely recall this was "fixed" at some point, and we serve SVGs natively now, at least in some cases? But a quick search of phab couldn't uncover the decision and/or how this was implemented. I assume we validate SVGs in some way to catch excessive file size/complexity before serving them as thumbnails?