Page MenuHomePhabricator

Incorrect scaling of .svg->.png images.
Closed, DeclinedPublic


Author: info

When uploading a .svg image mediawiki creates a .png version of it for easy viewing.
In the page I found that the image uses is which has
dimension 1024x724px. Yet in the image description page, the <img> tag holding the .png gives a width="1052"
height="744" pix, a scaling of 1.03%. Most browsers don't scale images very well using the <img width/height> tags,
especially not in scaling factors near 100%. In this case, the image looks especially ugly (as if it was drawn with
MS paint)

Further testing revealed that using an [[Image: -tag with sizes of over 1024 pix on this image, the 1024px png was
used, resulting in jagged or pixelized images. In using it with lower-resolution image tag sizes, the correct
behaviour (creating a 300pix PNG based on the SVG) was shown.

Version: unspecified
Severity: normal
OS: Linux
Platform: PC



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:14 PM
bzimport set Reference to bz5933.

This is because there's currently a rendering limit of 1024 pixels set.

info wrote:

Aha, I understand. Then is it not an option for SVG images (which are scalefree) to set the img tag size (<img width=... height=...>
to 1024 if the actual "size" (dimensions of the SVG document) are greater than these 1024 pixels. This solves the problems of ugly
jagged because scaled images in the preview, and in my view, does not introduce any problems. (The only problem of scaling down
pixel-sized structures to sized of less than one pixel is not valid as it is introduced by scaling to max 1024 pixels anyway.)

We don't support inline SVG at this time, only rasterized.
When inline SVG is supported, they will of course be client-side scaled.
Closing as INVALID again.

info wrote:

Well in the image description screen (the "wikiX.tld/wiki/Image:test.svg page) you DO have an inline SVG which is invalidly scaled. As
most users see this screen first when they upload the image, and see it severely jagged, they think the image is b0rked and upload
a .png instead (I am the "SVG authority" on the dutch wikipedia, at least 2 people told me they saw their SVG's were jagged and uploaded
a PNG instead - undesirable behaviour IMHO). This can *easily* be fixed: the <img> tag in the image page should just show the
width/height of the rendered image instead of using the .SVG sizes and invoking the client scaler. This is a waste at SVG scaling yields
much better results than upscaling of PNG.

Besides, for SVG images much bigger than 1024 pixels, you allready do this. For exampe: is rendered to 877x1023 pix and the image tag also reflects
this size. Correct behaviour! (the underlying SVG is 300000 pix wide).

info wrote:

Sorry, wrong understanding of the word "Inline" from my side. I'm not talking about inline SVG at all. I'm talking about the displaying
of the PNG rasterized from the SVG.

What happens is that mediawiki generates a PNG of size X,Y where X,Y=<1024. Yet, the <img> tag in the image page gives a width/height
of > 1024 (1052 in this case) - information it got from the SVG document size <SVG:SVG width="841.88977pt"> which is 1052.36 px.

Yet, for other images over 1024 px, you do get the width/height in the <img> tag <= 1024 where the source file is bigger!

This is, IMHO, different behaviour in two simialar cases, hence, a bug. The <img> tag should *not* specify a size greater than the size
of the rasterized PNG (=1024 right now), unless the user specifies it as such.

Assigning SVG bugs to Ariel -- need a cleanup pass to see what's fixed up by a librsvg upgrade, what can be resolved with fixes to our font configuration, what can be fixed on our end, and what still needs to be pushed upstream.

Image has nominal size 1000x1000

Pref size: 800x600
<img alt="Bestand:Honkbalposities.svg" src="" width="800" height="560">

Pref size: 1024x
<img alt="File:Honkbalposities.svg" src="" width="1000" height="700">

Seems this issue is fixed. No idea when.