stathissideris / dali

dali is a Clojure library for representing, exporting and manipulating the SVG graphics format.
291 stars 16 forks source link

mix-blend-mode ignored in rasterization? #14

Open IsaacWallis opened 5 years ago

IsaacWallis commented 5 years ago

Sorry if this is a bit of a dumb question, I'm newish, but, if I use this dali code:

(def blend                                                                                                                                  
    [:dali/page                                                                                                                                            
        [:defs                                                                                                                                                 
            (s/css                                                                                                                                                
                (str "rect {stroke: black; mix-blend-mode: difference;}\n"))]                                                                                        
        [:rect {:fill :pink} [80 60] [250 250]]                                                                                                                
        [:rect {:fill :blue} [140 120] [250 250] 80]                                                                                                           
        [:rect {:fill :turquoise} [180 180] [250 250]]])

then do (d/render-svg blend "diff1.svg") browsers and OSes show me an image like this: image

which is correct (I think).

Then if I do (d/render-png blend "diff1.png") I get this: image

It seems like the blend mode is being ignored in rasterization? Perhaps this is another batik bug?

stathissideris commented 5 years ago

Unfortunately, this is most likely because of a problem with batik, the java library dali uses internaly for rasterizing into PNGs. I say unfortunately, because it means that it's out of my control to fix. I've had other problems with batik, so you may want to use inkscape from the command line instead to produce PNGs: http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-Export.html