Project

ruby-batik

0.01
No commit activity in last 3 years
No release in over 3 years
Wrapper for SVG Transcoding using Apache Batik
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 1.0.0
>= 2.6.0
 Project Readme

Batik¶ ↑

Batik (xmlgraphics.apache.org/batik/) is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format for various purposes, such as display, generation or manipulation.

Quick Start¶ ↑

Be sure to add your batik installation to the classpath.

Rasterization¶ ↑

# Create a transcoder
transcoder = Batik::Transcoder.new

# Transcode an svg string to a string as a PNG
png = transcoder.to_png(svg_document)

# Transcode an svg string to a string as a JPEG
jpeg = transcoder.to_jpeg(svg_document)

# Transcode an svg string to a string as a PNG with some options
png = transcoder.to_png(svg_document, :dpi => 600, :indexed => 8)

# Transcode an svg string to a file
File.open('new.png', 'wb+') { |fp|
  fp.write(transcoder.to_png(svg_document))
}