Skip to content

HausnerR/batik-rasterize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

batik-rasterize

Clojure batik wrapper for rasterizing SVG graphics.

Inspired by Clojure dali library.

Clojars Project

Usage

Add dependency

[batik-rasterize "0.1.2"]

require it

(require '[batik.rasterize :as b])

and rasterize SVGs!

Functions

(b/parse-svg-uri "https://github.com/HausnerR/batik-rasterize/blob/master/clj_logo.svg")
(b/parse-svg-uri "clj_logo.svg")

Creates batik SVG document object from file/uri

(b/parse-svg-string "<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg>...</svg>")

Creates batik SVG document object from given SVG string

(b/render-svg-document document filename options)

Render rasterized version of SVG document, and save it at filename path.

Filename can be nil then result is returned as byte-array.

Available optional options:

  • :width - define output image width. By default it tries to determine width from source SVG,
  • :scale - you can define scale instead of width (2 times bigger, 0.5 times bigger etc.),
  • :type - output type. Possible values :jpg, :jpeg, :tif, :tiff, :png. Default by output extension,
  • :quality - define JPEG output quality. By default 95%
(b/render-svg-uri "clj_logo.svg" filename options)

Conjunction of parsing uri & rendering in one function

(b/render-svg-string "<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg>...</svg>" filename options)

Conjunction of parsing SVG string & rendering in one function

Known bugs

Due to bug in batik library, exporting to JPEG doesn't work :(

License

Copyright © 2017 Jakub Pachciarek

Distributed under the Apache License version 2.0.

About

Clojure batik wrapper for rasterizing SVG graphics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published