Page MenuHomePhabricator

set default dpi to 96 for rsvg
Open, Needs TriagePublic

Description

Steps to Reproduce:
render any file conatining height="00cm" width="000pt", as reported in https://github.com/RazrFalcon/resvg/issues/223

Actual Results:
currently it is rendered by 90dpi

Expected Results: (rsvg-convert -a -d 96dpi -p 96dpi)

  • 96dpi is the standard and should be imho be used
  • Inkscape changed from 90dpi to 96dpi since I guess 0.48.
  • 90dpi-Images leads to problems in optimizers such as svgo: https://github.com/svg/svgo/issues/1080 (96dpi should be used)

According to the https://www.w3.org/TR/CSS21/syndata.html#length-units reported in https://github.com/RazrFalcon/resvg/issues/223#issuecomment-590403131

The reference pixel is the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm's length. For a nominal arm's length of 28 inches, the visual angle is therefore about 0.0213 degrees. For reading at arm's length, 1px thus corresponds to about 0.26 mm (1/96 inch).

Event Timeline

AntiCompositeNumber changed the subtype of this task from "Bug Report" to "Task".Oct 14 2020, 5:54 PM

Two things that need to be looked at:

  • MediaWiki also calculates the size of SVG files. Our default DPI should match whatever MediaWiki does.
  • How would this affect the visual output, considering that most images are displayed with a fixed width in pixels?
  • MediaWiki also calculates the size of SVG files. Our default DPI should match whatever MediaWiki does.
  • How would this affect the visual output, considering that most images are displayed with a fixed width in pixels?

(1) the dpi is relevant if a file has (a) no viewBox and (b) height/width that are not in px
(2) the dpi of MediaWiki change the peviewsize if a file has (a) a viewBox and (b) height/width not in px

Since most images have viewBox and/or height/width in px, most pics won't be affected at all.

In case (2) If a file has a viewBox a the dpi of the svgrenderer does not affect the result.

In case (1) more will be rendered in the image (right and lower lower corner might get transparent), see https://github.com/RazrFalcon/resvg/issues/223#issue-569921192
e.g. 90dpi vs. 96dpi

Imho the height should not be calculated by Media-Wiki, because of T279241, see File:W3C_SVG_11_TestSuite_struct-frag-04-t.svg, so it should imho only set a width.


News: librsvg will change to 96 dpi in 2.52 . Since all others already changed to 96dpi, which is the standard for css (and therefore also for svg), it should get changed to 96, also it breaks files (will get a too large border in the left lower corner).

It is possible to run a bot (e.g. SVGWorkaroundBot) to change files with 90dpi to 96dpi, see convertion to px. Since files don't get re-rendered if the converter changes, a bot can fix all files, without noticing anyone that the dpi changed.

librsvg2.52 will set the default to 96dpi see https://gitlab.gnome.org/GNOME/librsvg/-/issues/646, maybe we should set 96dpi.