typst / svg2pdf

Converts SVG files to PDF.
Apache License 2.0
292 stars 38 forks source link

Use ICC profiles for colors #48

Closed LaurenzV closed 1 year ago

LaurenzV commented 1 year ago

Fixes #47.

Here you can find how the Typst test looks like with the new version.

typst.pdf

Everything still works, but colors are more accurate now (file size increased from 5.7MB to 6.2MB, but then again no one is going to embed 1600 SVGs into their documents, so the difference in negligible. Once we are able to share resources between Typst and svg2pdf, so that the ICC profile is only written once instead of for each image, the file size will probably become even smaller, because we added the approximation of SRGB to every group, which bloated the file quite a bit).

Unfortunately, this means I had to regenerate pretty much all reference images, but I checked them and they are still correct (and more accurate now).

Consider the following SVG:

<svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" version="1.1" >
    <rect x="0" y="0" width="200" height="200" fill="#111122" />

</svg>

Colors before the change (rendered with mupdf):

image

Colors after the change:

image
laurmaedje commented 1 year ago

Thank you!