简体   繁体   中英

How to change the foreground color in svg to png conversion?

I'm converting fontawesome 5 svg files to png using batik-rasterizer :

java -jar batik-rasterizer-1.10.jar -scriptSecurityOff "svg/" -d "output/" -m image/png -w 16 -h 16

How do I change the foreground color of the resulting icons?

EDIT:

According to the documentation , it's possible to change the background color:

-bg alpha . red . green . blue : specifies the background fill color as an ARGB quadruple, where each component is an integer in the range 0—255,

But there is no parameter for the foreground.

I found a solutions, in the batik rasterizer documentation I found the cssUser argument:

-cssUser file|uri : specifies the CSS user stylesheet to use in addition to any other referenced or embedded stylesheets,

With the following argument a CSS can be added to the conversion:

-cssUser convert.css

Here the css which makes the icons color red:

* {
    fill: #ff0000;
}

Here the complete call:

java -jar batik-rasterizer-1.10.jar -scriptSecurityOff "svg/" -d "output/" -m image/png -w 16 -h 16 -cssUser convert.css

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM