Could really use a deflate algorithm node for compression

This limitation has me in a tizzy today. :slight_smile:

Compress data with deflate algorithm using a compression level of 9 (best compression). pako is available as a global variable.

Trying to get a rendered mermaid diagram from kroki.io. Turns out deflate is a limitation of the hosted version.

  1. Encode the diagram as UTF8 in a Uint8Array (using the textEncode function declared above)
  2. Compress data with deflate algorithm using a compression level of 9 (best compression). pako is available as a global variable.
  3. Encode to Base64 using btoa global function
  4. Replace + and / characters to make it “URL safe”

Thanks.

Hi Chris4,

Here is something that could help you

import base64;
import zlib;

text = _input.item.json.‘YOUR TEXT’

encrypted_text = base64.urlsafe_b64encode(zlib.compress(t.encode(‘utf-8’), 9)).decode(‘ascii’)

_input.item.json.myNewField = str(encrypted_text)

return _input.item

You need to use 2 blocs (1 for code, 1 for http request to Kroki)

After you can download your image

Hope this will help