ropensci / rsvg

SVG renderer for R based on librsvg2
Other
95 stars 1 forks source link

Raw dimensions differ between Windows and Ubuntu #37

Closed willgearty closed 1 year ago

willgearty commented 1 year ago

I've found that the dimensions of the output of rsvg_raw() appear to be somewhat OS-dependent.

Here's a reproducible example with R 4.2.2:

# on windows
test <- rsvg_raw("https://images.phylopic.org/images/35787884-905e-4d24-9111-f9b93fe47834/vector.svg")
dim(test)
[1]      4    1729     944
# on ubuntu 22.04
test <- rsvg_raw("https://images.phylopic.org/images/35787884-905e-4d24-9111-f9b93fe47834/vector.svg")
dim(test)
[1]      4    1728     943

When I look at the original svg file, the width is 1728.7859 and the height is 943.78149, so perhaps this is a rounding issue?

jeroen commented 1 year ago

It's probably caused by different versions of librsvg, rather than the OS per sé.

willgearty commented 1 year ago

Ah, you are right, the Windows package comes with librsvg 2.48.8, whereas I installed librsvg2-dev 2.52.5 in my Ubuntu environment. I don't see any other versions available for download for Ubuntu via apt, unless I'm looking in the wrong place? Or maybe there's a way to update the version on my Windows machine?

Ultimately, this is just for my R CMD checks via Github Actions. Is there a way to guarantee the librsvg version is consistent across the different GA machines?

willgearty commented 1 year ago

I was able to resolve this by switching to using Ubuntu 20.04 for my Github Actions tests. It looks like the most recent version of librsvg on Ubuntu 20.04 is only 2.48.9, which seems close enough to 2.48.8 to not cause the issue anymore.