0

I want to convert the Base64 I get from an API into an image in the iOS scriptable app. Here is my current code:

let image = Image.data(Data.fromBase64String(response.icon))

How could I convert the base64 into an image?

The error:

2021-08-19 12:31:07: Error on line 20:23: TypeError: Image.data is not a function. (In 'Image.data(Data.fromBase64String(response.icon))', 'Image.data' is undefined)
VLAZ
  • 26,331
  • 9
  • 49
  • 67
Godz
  • 1
  • 1
  • 4
  • What's the problem with the code? Isn't it doing what you're asking for? If there are any errors or wrong results, you should describe that in the question. – jps Aug 19 '21 at 15:46
  • Whoops sorry, just updated it. Sadly it doesn’t do what I want it to do and throws an undefined. – Godz Aug 19 '21 at 16:32

2 Answers2

1

You do not call the correct initialiser for Image ( It’s .fromData ) :

let image = Image.fromData(Data.fromBase64String(response.icon))
Ptit Xav
  • 3,006
  • 2
  • 6
  • 15
0
let image = await new Request("data:image/png;base64,AAAAAAA").loadImage()
Lentin
  • 1