From rtomayko at gmail.com Sun Sep 17 02:29:04 2006 From: rtomayko at gmail.com (Ryan Tomayko) Date: Sun, 17 Sep 2006 02:29:04 -0400 Subject: [Scruffy-devel] Scruffy::Rasterizers::RSVGRasterizer Message-ID: Hi, I've created a librsvg [1] rasterizer for Scruffy. librsvg is written in C, uses libxml2 for parsing and cairo as a backend. It is used most heavily by the GNOME project and Ruby bindings [2] are made available by the Ruby/GNOME2 project [3]. A patch including only the new `scruffy/rasterizers/rsvg_rasterizer.rb` file and the additional require line in `scruffy/rasterizers.rb` is attached. The RSVGRasterizer has both pros and cons when compared to the existing RMagick and Batik rasterizers: Completeness: librsvg supports opacity everywhere and likely other things that the RMagick/ImageMagick SVG implementation lacks. From what I've read thus far, librsvg is a fairly complete implementation of SVG 1.1 static missing only some text functionality (vertical text, text on a path). The resulting image quality (and java not being an option) is what drove me to put the rasterizer together. Performance and resource use is most likely going to be considerably better than the Batik rasterizer since librsvg is in C and it has ruby bindings. I have not run benchmarks. The one downside I've found is that librsvg+bindings are a bit of a PIA to install (and in more ways than one). First, the ruby bindings don't seem to be packaged for a variety of systems and when packages are available they usually bring in a ton of other shit via frivolous dependency. I've been able to get the bindings running on both FreeBSD 6.1-RELEASE and MacOS X 10.4.7 (via darwinports). I've also tried under Fedora Core 5 but have been unsuccessful thus far. FreeBSD was a breeze: $ sudo portupgrade -N graphics/ruby-rsvg2 OS X with Darwin/MacPorts was a bit harder due to dependencies not being marked properly but something like the following should get you there: $ sudo port install scrollkeeper rb-gnome Test whether the bindings are installed properly using: $ irb >> require 'rsvg2' => true >> RSVG::BINDING_VERSION.join('.') => "0.15.0" >> RSVG::BUILD_VERSION.join('.') => "2.12.7" (output is from current darwinports version) The problem on both FreeBSD and OS X is that the ports on both systems want to bring in a whole mess of crap that isn't really necessary. In both cases all of X11, GNOME, gtk, etc. were installed. Under FreeBSD, I actually had to remove NO_GUI, NO_X, and WITHOUT_X11 from `/etc/make.conf` on a headless box in order to get the ports to build cleanly. From what I can tell, a great majority of these dependencies are bloat when all you want to do is rasterize SVG. I expect the situation to be no different on Linux systems. The librsvg project page states that only libxml2, glib, and cairo are required so it should be possible to get the dependency situation down to a reasonable level (i.e. the issue is on the packaging side). When I get time I plan on pulling tarballs and building from source the old-fashioned way to see exactly what is and isn't required. A gem that builds a big honkin static library with bindings may be an interesting way to spend a couple of hours. All that being said, I've been happy with the results thus far and feel the librsvg rasterizer has the best combinations of completeness and performance if you can satisfy the dependencies. [1] http://librsvg.sourceforge.net/ librsvg [2] http://ruby-gnome2.sourceforge.jp/hiki.cgi?Ruby%2FRSVG Ruby/RSVG API documentation [3] http://ruby-gnome2.sourceforge.jp/ Ruby GNOME Project Thanks, -- Ryan Tomayko rtomayko at gmail.com http://naeblis.cx/rtomayko/ http://lesscode.org/ -------------- next part -------------- A non-text attachment was scrubbed... Name: scruffy-librsvg-rasterizer.diff Type: application/octet-stream Size: 1386 bytes Desc: not available Url : http://rubyforge.org/pipermail/scruffy-devel/attachments/20060917/6fab0d4f/attachment.obj From rtomayko at gmail.com Tue Sep 19 00:34:10 2006 From: rtomayko at gmail.com (Ryan Tomayko) Date: Tue, 19 Sep 2006 00:34:10 -0400 Subject: [Scruffy-devel] Scruffy::Rasterizers::RSVGRasterizer In-Reply-To: <2F53B871-4905-494C-BD01-5EE8FE21D820@nagilum.com> References: <2F53B871-4905-494C-BD01-5EE8FE21D820@nagilum.com> Message-ID: On 9/18/06, Brasten Sager wrote: > The Scruffy code is a little messed up and the moment -- in the > middle of some invasive changes -- but as soon as I'm able to check > in a working copy I'll apply your patch and add some of your notes > here to the docs. Sounds good. I'm looking forward to seeing your changes as I've been hacking away at internals to get graphs to come out with some odd customizations I require (adding font-family attributes, dynamically resizing renderers/layouts, etc). I would send over some more patches for review but I did a lot of this in a hurry and it sounds like patches would just get in your way atm. Some invasive changes will be the perfect motivation for me to go back over my changes and try to extract something that's contributable. The overall design seems like it has legs. Most stuff is customizable via options and what's not can easily be customized by plugging in a new component, renderer, rasterizer, etc. Looks really good for being so early. > Keep me updated on any headway you make into trimming down > dependencies and whatnot. A lot of people don't want to deal with > ImageMagick/RMagick for this, and frankly ImageMagick doesn't do a > very good job of rendering SVG images. Oh, the resulting raster images are head and shoulders above ImageMagick's. Opacity and font handling are superb -- it just works. If you want to play with the rendering capabilities, there's a command line tool, `rsvg`, that gets laid down with librsvg and resembles Batik's CLI. > It sounds like librsvg has > the *potential* for being a much more compact installation once the > excess crap is trimmed down. I've built from source and here's what I was able to get it down to: http://pastie.caboo.se/13919 Not fun but it shows that with a little massaging you can get the dependency list down quite a bit (glib2, gdk-pixbuf, cairo, and libcroco). When I get some free time I'd still like to toy with the idea of creating a gem that will build a big fat static library if that sort of thing is even possible. -- Ryan Tomayko rtomayko at gmail.com http://naeblis.cx/ http://lesscode.org/