Converting base64 png to image url


So I found some weird behaviour regarding to how getting widget prompts work in custom widgets, in particular the image urls.

  1. We use a custom widget that we are creating drawings with, that we save to a Tulip table - like a gallery - as images. These are in a base64 encoded format but saved to an image url table field.
  2. We are also creating pictures by phone with the built-in camera widget, which we store in the same gallery table. By using that widget, for these images we have image urls stored in the table in the same field.

And here comes the problematic part.
We are currently working on a custom widget, to achieve looping while staying in one step and to achieve scrollability. In this custom widget we need to be able to display both the pictures and drawings. While displaying the images with the legit image urls works just fine, when we are trying to use the getValue function on the same prompt, when it contains a base64 text, it always returns a null value. I tried to create a PoC in order to find out what we can do with this, and realized that by using a “text” type prompt, the custom widget can read the base64 without a problem, therefore I can display it too. However while saving a drawing in the base64 format to a table in an image url field is possible, it isn’t if we try to do the same into a text field, because in nearly every case the size of the text is bigger than 2.5kb.
Saving or converting the drawing to a png with another custom widget and uploading it is also not possible, because we can only use image url-s as event return value types and the url is not yet generated at this point. The only possible solution that I found is that, while a table field of text cannot contain bigger text than 2.5kb, a text variable can, so when loading in the table record, we can convert the image url field to a string using the expression editor which we can store and give back to the custom widget, and trying to use some regex magic to sort them out. Although it’s development is still in progress and I’m not sure about the eligibility of the performance also.

Did you face any issues like this before? If you have any possible solutions, please don’t hold yourselves back to share it. :smiley:

Hey @kobe, this is a really interesting problem you’re sorting out. Curious to see what the group has to say.