Forum

VL.HTMLToImage

Uses wkhtmltoimage / NReco.ImageGenerator to convert HTML to SKImage.

Not sure about the categorization.
String version needs absolute paths to be able to load external files.
Transparency is rather hacky (ignores values defined in css) just sets background to transparent.

3 Likes

I’ve also used this converter once, maybe i can find the example patch. if you can, the more general image format is IImage, which can be consumed by most VL libraries: https://vvvv.org/blog/vl-image-exchange-interface

The N.Reco wrapper exposes two GenerateImageFromFile methods one that takes a stream and writes to it and one thats outputs MutableArray<byte>. I am using the latter. GenerateImage “supports” the following file-formats: BMP, JPG, PNG. When trying those with ToImage MutableArray, JPG crashes VL. PNG looks totally garbled no matter which PixelFromat. BMP is flipped and I couldn’t figure out a way to change the byteorder to make it work. Even if BMP wouldn’t be flipped, it doesn’t seem to support alpha anyway.

image

Skia FromBytes / FromEncodedData just work, though I am wondering which one to use.

Yes, the IImage interface expects uncompressed pixel data. so BMP seems to be the correct choice. otherwise the HTML renderer would compress, just to decompress right after it.

usually you have to set the format to some BGR(A) order.

Unfortunately transparency only works with PNG.

sounds like a bug report for the html to image library.

i’ve checked my patch and i’ve also used PNG for some reason, but was writing directly into a stream using the Bitmap nodes:

image

@tonfilm is this System.IO.MemoryStream? Can’t find a Create that doesn’t need any input parameters…

The if is for ensuring the execution order I guess?

You can click OK without selecting any input…

Yes, exactly.

Ah ok thanks. Would be nice to have some kind of visual indication for that in the nodebrowser.

2 Likes

Yes, I also have trouble adjusting to this, even though I know already (and I had to be told about it as well to find it in the first place).
It should be another entry at the top of the same list to choose from.

yes absolutely, this issue is on our list and we are aware it’s high priority. pops up every other week.

1 Like