lobingera / rsvg.jl Goto Github PK
View Code? Open in Web Editor NEWadaptation of the rsvg lib
License: Other
adaptation of the rsvg lib
License: Other
Hey @lobingera, would it be possible for you to release a new version of the package? I needed the definition of RsvgRectangle, and I've hacked around it for now but it would be great to have from Rsvg itself.
Best,
Anshul.
A simple using Rsvg
from a julia REPL on Mac opens up an extra icon on the Mac dock, which seems not ideal. This is actually caused by using Gtk
, which already opens that extra icon.
I'm not sure how one could work around this, but it seems not ideal. I guess one question is whether Rsvg.jl really needs a dependency on a full window toolkit? Might there be some way to get rid of that dependency? Or some other idea?
We are using Rsvg.jl in VegaLite.jl to implement all sorts of file export features, and it works great. But it is weird that if someone does using VegLite
, that a new icon pops up on Macs.
I'm using AutomotiveVisualization.jl to render scenarios from AutomotiveSimulator.jl and had problems after updating some packages. I'm not sure what the right place to put this issue is, but I tracked it down to Librsvg_jll. Basically, it was working with version 2.42.2 and is not working anymore on 2.52.4, so I'm opening it here.
I created a MWE independent of those packages using this SVG from AutomotiveVisualization.jl:
I'm not very experienced with Cairo so this might not be the best way to do stuff, it's just what I saw being done in those packages.
using Cairo
using Rsvg
using Reel
const CARFILE = "racing_car_top_view.svg"
function render_car(angle = 0)
surface = CairoSVGSurface(IOBuffer(), 2000, 2000)
ctx = creategc(surface)
r = open(CARFILE, "r") do carfile
car_svg = read(carfile, String)
Rsvg.handle_new_from_data(car_svg)
end
d = Rsvg.handle_get_dimensions(r)
translate(ctx, 1000, 1000)
rotate(ctx, angle)
translate(ctx, -d.width / 2, -d.height / 2)
Rsvg.handle_render_cairo(ctx, r)
return surface
end
function write_to_svg(surface, filename)
finish(surface)
seek(surface.stream, 0)
open(filename, "w") do io
write(io, read(surface.stream, String))
end
end
function animate()
animation = roll(fps = 10, duration = 2π) do t, dt
render_car(t)
end
end
angle = -0.3
surface = render_car(angle)
write_to_svg(surface, "out.svg")
surface = render_car(angle)
Cairo.write_to_png(surface, "out.png")
animation = animate()
write("ani.gif", animation)
animation = animate()
write("ani.mp4", animation)
Output with Librsvg_jll 2.42.2:
Output with Librsvg_jll 2.52.4:
julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
was detected in #16, destroy calls are not connected to finalize anymore.
Hi, I'm using Rsvg.jl on Julia 0.6.4 and am saving a PlotlyJS.jl graphic in pdf. It saves but the plot only shows axes with no data plotted.
I think this could be an issue with my Rsvg install, which I've tried to fix below. If it's an issue with PlotlyJS.jl, maybe @sglyon can help.
Here's a reprex using PlotlyJS.jl to plot and Rsvg.jl to export.
using PlotlyJS
using Rsvg
function heatmap1()
plot(heatmap(z=[1 20 30; 20 1 60; 30 60 1]))
end
h = heatmap1()
PlotlyJS.savefig(h, "example_reprex.pdf", js=:remote)
outputs:
example_reprex.pdf
When I rebuild Rsvg.jl I see
julia> Pkg.build("Rsvg")
INFO: Building Homebrew
Already up-to-date.
INFO: Building Cairo
INFO: Building Rsvg
Error: No available formula with the name "libgio"
Error: No available formula with the name "libgio"
I cannot use both Gadfly and VegaLite for plotting because of a strange issue that I think comes from Rsvg.jl
, but it's maybe also related to Homebrew.jl
(@staticfloat)?
The installation runs fine (I tried reinstalling everything, from scratch, checkout master etc.), but testing Rsvg.jl
always gives the following error:
objc[47481]: Class GNotificationCenterDelegate is implemented in both /usr/local/opt/glib/lib/libgio-2.0.0.dylib (0x111399498) and /Users/ken/.julia/packages/Homebrew/s09IX/deps/usr/lib/libgio-2.0.dylib (0x129254498). One of the two will be used. Which one is undefined.
I tried linking inside julia package folders manually to system libgio
(installed through brew on my system), but although the errors go away, the plots are all scrambled.
Any help appreciated, thanks!
(v1.0) pkg> test Rsvg
Testing Rsvg
Status `/var/folders/h9/8wp6_1kx6_v6wm7_vy5w_pbm0000gn/T/tmp1eCjdp/Manifest.toml`
[9e28174c] BinDeps v0.8.10
[b99e7846] BinaryProvider v0.5.3
[e1450e63] BufferedStreams v1.0.0
[159f3aea] Cairo v0.5.6
[3da002f7] ColorTypes v0.7.5
[5ae59095] Colors v0.9.5
[34da2185] Compat v1.5.1
[53c48c17] FixedPointNumbers v0.5.3
[a2bd30eb] Graphics v0.4.0
[0862f596] HTTPClient v0.2.1
[d9be37ee] Homebrew v0.7.1
[682c06a0] JSON v0.20.0
[b27032c2] LibCURL v0.4.1
[522f3ed2] LibExpat v0.5.0
[2ec943e9] Libz v1.0.0
[77ba4419] NaNMath v0.3.2
[189a3867] Reexport v0.2.0
[c4c386cf] Rsvg v0.2.3+ #master (https://github.com/lobingera/Rsvg.jl.git)
[30578b45] URIParser v0.4.0
[c17dfb99] WinRPM v0.4.2
[2a0f44e3] Base64 [`@stdlib/Base64`]
[ade2ca70] Dates [`@stdlib/Dates`]
[8bb1440f] DelimitedFiles [`@stdlib/DelimitedFiles`]
[8ba89e20] Distributed [`@stdlib/Distributed`]
[b77e0a4c] InteractiveUtils [`@stdlib/InteractiveUtils`]
[76f85450] LibGit2 [`@stdlib/LibGit2`]
[8f399da3] Libdl [`@stdlib/Libdl`]
[37e2e46d] LinearAlgebra [`@stdlib/LinearAlgebra`]
[56ddb016] Logging [`@stdlib/Logging`]
[d6f4376e] Markdown [`@stdlib/Markdown`]
[a63ad114] Mmap [`@stdlib/Mmap`]
[44cfe95a] Pkg [`@stdlib/Pkg`]
[de0858da] Printf [`@stdlib/Printf`]
[3fa0cd96] REPL [`@stdlib/REPL`]
[9a3f8284] Random [`@stdlib/Random`]
[ea8e919c] SHA [`@stdlib/SHA`]
[9e88b42a] Serialization [`@stdlib/Serialization`]
[1a1011a3] SharedArrays [`@stdlib/SharedArrays`]
[6462fe0b] Sockets [`@stdlib/Sockets`]
[2f01184e] SparseArrays [`@stdlib/SparseArrays`]
[10745b16] Statistics [`@stdlib/Statistics`]
[8dfed614] Test [`@stdlib/Test`]
[cf7118a7] UUIDs [`@stdlib/UUIDs`]
[4ec0a83e] Unicode [`@stdlib/Unicode`]
Test Summary: | Pass Total
dimensions of known images | 8 8
Test Summary: | Pass Total
render to png | 4 4
objc[47481]: Class GNotificationCenterDelegate is implemented in both /usr/local/opt/glib/lib/libgio-2.0.0.dylib (0x111399498) and /Users/ken/.julia/packages/Homebrew/s09IX/deps/usr/lib/libgio-2.0.dylib (0x129254498). One of the two will be used. Which one is undefined.
(process:47481): librsvg-CRITICAL **: 22:12:27.907: rsvg_handle_new_from_stream_sync: assertion 'G_IS_INPUT_STREAM (input_stream)' failed
signal (11): Segmentation fault: 11
in expression starting at /Users/ken/.julia/packages/Rsvg/uwc9D/test/runtests.jl:60
getproperty at ./sysimg.jl:18 [inlined]
getindex at ./refvalue.jl:32 [inlined]
handle_new_from_data at /Users/ken/.julia/packages/Rsvg/uwc9D/src/calls.jl:109
test_render_string_to_png at /Users/ken/.julia/packages/Rsvg/uwc9D/test/test.jl:52
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1831
test_render_string_to_png at /Users/ken/.julia/packages/Rsvg/uwc9D/test/test.jl:49
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1831
macro expansion at /Users/ken/.julia/packages/Rsvg/uwc9D/test/runtests.jl:63 [inlined]
macro expansion at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Test/src/Test.jl:1083 [inlined]
top-level scope at /Users/ken/.julia/packages/Rsvg/uwc9D/test/runtests.jl:62
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1831
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:799
jl_parse_eval_all at /Users/osx/buildbot/slave/package_osx64/build/src/ast.c:838
jl_load at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:839 [inlined]
jl_load_ at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:846
include at ./boot.jl:317 [inlined]
include_relative at ./loading.jl:1044
include at ./sysimg.jl:29
include at ./client.jl:392
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1831
do_call at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:324
eval_stmt_value at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:363 [inlined]
eval_body at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:682
jl_interpret_toplevel_thunk_callback at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:806
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x10a72fc0f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:815
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:805
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:754
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:622
eval at ./boot.jl:319
exec_options at ./client.jl:243
_start at ./client.jl:425
true_main at /Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia (unknown line)
main at /Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia (unknown line)
Allocations: 5877126 (Pool: 5876152; Big: 974); GC: 12
ERROR: Package Rsvg errored during testing
julia> versioninfo(verbose=true)
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
uname: Darwin 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64 i386
CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz:
speed user nice sys idle irq
#1 2800 MHz 83706 s 0 s 68444 s 577018 s 0 s
#2 2800 MHz 4185 s 0 s 3715 s 721189 s 0 s
#3 2800 MHz 88050 s 0 s 35528 s 605526 s 0 s
#4 2800 MHz 4511 s 0 s 3665 s 720909 s 0 s
#5 2800 MHz 74952 s 0 s 25474 s 628670 s 0 s
#6 2800 MHz 4765 s 0 s 3308 s 721009 s 0 s
#7 2800 MHz 63477 s 0 s 19159 s 646455 s 0 s
#8 2800 MHz 4920 s 0 s 2895 s 721264 s 0 s
Memory: 16.0 GB (441.94921875 MB free)
Uptime: 258904.0 sec
Load Avg: 1.4580078125 1.60009765625 1.673828125
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
Environment:
XPC_FLAGS = 0x0
PATH = /usr/local/sbin:/Users/ken/anaconda3/bin:/Users/ken/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
TERM = xterm-256color
HOME = /Users/ken
julia>
I receive the following error when trying to build Rsvg.jl on Julia 1.1.0 on a Macbook pro running High Sierra 10.13.6. Can you help me solve this? We're in the final stage of a development project so it's rather urgent.
The error I receive is:
ERROR: LoadError: LoadError: LoadError: Unable to load
librsvg (/Users/George/.julia/packages/Homebrew/s09IX/deps/usr/lib/librsvg-2.2.dylib)
Please re-run Pkg.build(package), and restart Julia.
Stacktrace:
[1] error(::String, ::String) at ./error.jl:42
[2] @checked_lib(::LineNumberNode, ::Module, ::Any, ::Any) at /Users/George/.julia/packages/Rsvg/uwc9D/deps/deps.jl:11
[3] include at ./boot.jl:326 [inlined]
[4] include_relative(::Module, ::String) at ./loading.jl:1038
[5] include at ./sysimg.jl:29 [inlined]
[6] include(::String) at /Users/George/.julia/packages/Rsvg/uwc9D/src/Rsvg.jl:2
[7] top-level scope at none:0
[8] include at ./boot.jl:326 [inlined]
[9] include_relative(::Module, ::String) at ./loading.jl:1038
[10] include(::Module, ::String) at ./sysimg.jl:29
[11] top-level scope at none:2
[12] eval at ./boot.jl:328 [inlined]
[13] eval(::Expr) at ./client.jl:404
[14] top-level scope at ./none:3
in expression starting at /Users/George/.julia/packages/Rsvg/uwc9D/deps/deps.jl:21
in expression starting at /Users/George/.julia/packages/Rsvg/uwc9D/deps/deps.jl:21
in expression starting at /Users/George/.julia/packages/Rsvg/uwc9D/src/Rsvg.jl:5
ERROR: LoadError: Failed to precompile Rsvg [c4c386cf-5103-5370-be45-f3a111cca3b8] to /Users/George/.julia/compiled/v1.1/Rsvg/aWLhH.ji.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1197
[3] _require(::Base.PkgId) at ./loading.jl:960
[4] require(::Base.PkgId) at ./loading.jl:858
[5] require(::Module, ::Symbol) at ./loading.jl:853
[6] include at ./boot.jl:326 [inlined]
[7] include_relative(::Module, ::String) at ./loading.jl:1038
[8] include(::Module, ::String) at ./sysimg.jl:29
[9] top-level scope at none:2
[10] eval at ./boot.jl:328 [inlined]
[11] eval(::Expr) at ./client.jl:404
[12] top-level scope at ./none:3
in expression starting at /Users/George/.julia/packages/VariantVisualization/cbN7w/src/VariantVisualization.jl:6
Just ran into the following error on master
on Windows:
Got exception outside of a @test
ccall: could not find function g_error_free in library C:\Users\david\.julia\packages\Rsvg\0R8IA\deps\usr\bin\librsvg-2-2.dll
Stacktrace:
[1] handle_new_from_data(::String) at C:\Users\david\.julia\packages\Rsvg\0R8IA\src\calls.jl:111
@giordano, any idea?
I think that means we should probably hold off from tagging a release...
Julia Version 1.0.3
Platform Info:
OS: Linux (x86_64-conda_cos6-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-1620 v4 @ 3.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)
Environment:
JULIA_NUM_THREADS = 4
┌ Error: Error building Rsvg
:
│ ERROR: LoadError: None of the selected providers can install dependency rsvg.
│ Use BinDeps.debug(package_name) to see available providers
│
│ Stacktrace:
│ [1] error(::String) at ./error.jl:33
│ [2] satisfy!(::BinDeps.LibraryDependency, ::Array{DataType,1}) at /home/cllcentosvm/.julia/packages/BinDeps/ZEval/src/dependencies.jl:949
│ [3] satisfy!(::BinDeps.LibraryDependency) at /home/cllcentosvm/.julia/packages/BinDeps/ZEval/src/dependencies.jl:922
│ [4] top-level scope at /home/cllcentosvm/.julia/packages/BinDeps/ZEval/src/dependencies.jl:977
│ [5] include at ./boot.jl:317 [inlined]
│ [6] include_relative(::Module, ::String) at ./loading.jl:1044
│ [7] include(::Module, ::String) at ./sysimg.jl:29
│ [8] include(::String) at ./client.jl:392
│ [9] top-level scope at none:0
│ in expression starting at /home/cllcentosvm/.julia/packages/Rsvg/uwc9D/deps/build.jl:33
└ @ Pkg.Operations /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1097
I can not see any reason why the following two methods:
set_default_dpi(dpi::Float64)
handle_set_dpi(handle::RsvgHandle, dpi::Float64)
Should not accept integers. Perhaps it is better to type the arguments as Real
, to accept both floats and integers of any type?
Creating a large plot with VegaLite.jl (cc @fredo-dedup) and saving it as a PNG segfautls. It seems that this happens at Rsvg.handle_get_dimensions
:
using DataFrames
using VegaLite
n = 60000
df = DataFrame(X = rand(2n),
Y = rand(2n),
Z = [repeat([:a], n); repeat([:b], n)])
plt = df |> @vlplot(:point, x = :X, y = :Y, row = :Z)
svgstring = VegaLite.convert_to_svg(plt)
using Rsvg
r = Rsvg.handle_new_from_data(svgstring);
d = Rsvg.handle_get_dimensions(r);
I'm using Rsvg v0.2.2, Julia 1.0.1/master and librsvg 2.42.6 in Arch Linux.
I am having trouble compiling this on a fresh install of Julia 1.7 on MacOS [M1 ARM]
julia> using Rsvg
ERROR: InitError: UndefVarError: librsvg not defined
Stacktrace:
[1] set_default_dpi
@ ~/.julia/packages/Rsvg/dClzP/src/calls.jl:52 [inlined]
[2] __init__()
@ Rsvg ~/.julia/packages/Rsvg/dClzP/src/Rsvg.jl:16
[3] _include_from_serialized(path::String, depmods::Vector{Any})
@ Base ./loading.jl:768
[4] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
@ Base ./loading.jl:854
[5] _require(pkg::Base.PkgId)
@ Base ./loading.jl:1097
[6] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:1013
[7] require(into::Module, mod::Symbol)
@ Base ./loading.jl:997
during initialization of module Rsvg
(v1.0) pkg> add Rsvg
Resolving package versions...
Installed Rsvg ─ v0.2.1
Updating `Project.toml`
[c4c386cf] + Rsvg v0.2.1
Updating `Manifest.toml`
[c4c386cf] + Rsvg v0.2.1
Building Rsvg → `~/.julia/packages/Rsvg/AEdKr/deps/build.log`
┌ Error: Error building `Rsvg`:
│ ERROR: LoadError: LoadError: UndefVarError: is_linux not defined
│ Stacktrace:
│ [1] top-level scope at none:0
│ [2] eval at ./boot.jl:319 [inlined]
│ [3] @static(::LineNumberNode, ::Module, ::Any) at ./osutils.jl:19
│ [4] include at ./boot.jl:317 [inlined]
│ [5] include_relative(::Module, ::String) at ./loading.jl:1038
│ [6] include(::Module, ::String) at ./sysimg.jl:29
│ [7] include(::String) at ./client.jl:388
│ [8] top-level scope at none:0
│ in expression starting at /Users/abmlab/.julia/packages/Rsvg/AEdKr/deps/build.jl:8
│ in expression starting at /Users/abmlab/.julia/packages/Rsvg/AEdKr/deps/build.jl:8
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1068
@lobingera Thanks for merging #16! Any chance you could also tag a new release soon? I'm still hoping to get everything working on juliabox before Wed :)
I think we need to think a bit in what order we release things here. Here is my suggestion:
THEN, second phase
The story then would be that the 0.2.x series is BinDeps.jl based, 0.3.x is BinaryProvider based, and 1.x.y is artifact based (and Julia 1.3 and newer only).
Could the Rsvg module be precompiled?
Hi,
I have this wired error during init of module Rsvg for a quiet long time on a specific windows 7 machine, I tried update windows, delete and reinstall Julia packages, including Gtk.jl and Cairo.jl, but still not working. On the other hand, the other windows 7 machine works fine without this error.
I have no idea how this come, maybe some system configuration?
I am running Julia 0.6.3, and Rsvg.jl is v0.2.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.