Image, File and JavaScript API in general

Hi,

Sorry I’m new to Fuse, I have built couple of screens but I’m still trying to find my way around. I have a specific question, and a more general related one.

After I take a picture with Camera.takePicture(1000, 1200).then(function(file) my promise gets File handle (I presume).
Let’s say I want to send my file parameter to ImageTools.getBase64FromImage(image), I would like to get a image handle from a file.
I can’t find an API to go create an image object from a file handle. I tried with FileReader.readAsDataURL but without success. I’m searching for a way to stick with ImageTools.getBase64FromImage but I’m left with creating an image from a file.

In general, is there a JavaScript API I can refer to? The Image class documentation shows me the possible markups options not how to create an image object I can send to ImageTools for instance.

Don’t apologise for being new! Welcome!

The idea behind Image objects and this API was you would fetch images from the camera, cameraroll or imagetools apis, not create them in other ways. This is because our implementation uses a disk cache to store images (in general terms you cannot realistically keep the huge images captured by modern cell cameras in memory) and you cannot easily guarantee a valid native file path without native knowledge, which would significantly complicate the JS end.

Note also that neither takePicture or any of the APIs return a File. Where did you read an example returning a File? The actual object returned is a simple JS object with some data fields, such as path which is commonly the one you want if you intend to display the image on screen.

To pipe an image from the camera into imagetools just send the same object you get from takePicture right into the imagetools APIs.