svg
Overview
- Name:
- svg
- Namespace:
- http://www.litwan.com/yanel/resource/1.0
- Universal Name:
- <{http://www.litwan.com/yanel/resource/1.0}svg/>
- Description:
- dedicated svg resource type which provides additional png, jpg and html views
- Java Class:
- com.litwan.yanel.impl.resources.svg.SVGResource
Resource Configuration
- jpg-quality
- float between 0.1 and 1
- image-width
- width of the rendered bitmap
- disable-cache
- do not cache images. always recalculate them.
- cache-root-path
- where the cache is created. default is '/cached-images'
view config
<yanel:custom-config>
<views>
<view id="default" type="custom">
<mime-type>image/svg+xml</mime-type>
</view>
<view id="svg" type="custom">
<mime-type>image/svg+xml</mime-type>
</view>
<view id="jpg" type="custom">
<mime-type>image/jpeg</mime-type>
</view>
<view id="png" type="custom">
<mime-type>image/png</mime-type>
</view>
<view id="html" type="jelly-XML">
<template>rthtdocs:/html.jelly</template>
<mime-type>text/html</mime-type>
</view>
</views>
</yanel:custom-config>
Bitamap Formats
Supported image formats are jpg, png.
Basic Example:
To resize images first you need to register the resource type as usual. add following line with the correct path to your (local.)resource-types.xml
<resource-type src="/home/simon/src/3k3-yanel-contrib/resource-types/svg/" compile="true"/>
after this you need to add a matcher to the map.rc-map file e.g.
<matcher pattern="**.svg.png" rcpath="/svg.yanel-rc"/> <matcher pattern="**.svg.jpg" rcpath="/svg.yanel-rc"/> <matcher pattern="**.svg.html" rcpath="/svg.yanel-rc"/> <matcher pattern="**.svg" rcpath="/svg.yanel-rc"/>
then you need to create an image-resizer.yanel-rc file with following content.
<?xml version="1.0"?>
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="svg" namespace="http://www.litwan.com/yanel/resource/1.0"/>
<yanel:property name="jpg-quality" value="1"/>
<yanel:custom-config>
<views>
<view id="default" type="custom">
<mime-type>image/svg+xml</mime-type>
</view>
<view id="svg" type="custom">
<mime-type>image/svg+xml</mime-type>
</view>
<view id="jpg" type="custom">
<mime-type>image/jpeg</mime-type>
</view>
<view id="png" type="custom">
<mime-type>image/png</mime-type>
</view>
<view id="html" type="jelly-XML">
<template>rthtdocs:/html.jelly</template>
<mime-type>text/html</mime-type>
</view>
</views>
</yanel:custom-config>
</yanel:resource-config>
now if you have an svg on http://demo.yanel-contribution.3k3.org/svg/test.svg you can view a rasterized version under http://demo.yanel-contribution.3k3.org/svg/test.svg.png
IMPORTANT
if you use this resource-type in a headless environement set Djava.awt.headless=true Where as this seems to still has some problems under certain circumstances
Demo
http://demo.yanel-contribution.3k3.org/svg/test.svg.html
Change Log
Source
browse svn repo: http://trac.yanel-contribution.3k3.org/browser/resource-types/svg
checkout source:
svn co https://svn.3k3.org/repos/public/yanel/resource-types/svg
License
Related Links
- http://xmlgraphics.apache.org/batik/tools/rasterizer.html Batik Rasterizer
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)