Search code examples
javascriptimagejszip

retrieve an image from a JSZip archive


I stored an image in a JSZip archive and need to retrieve it and display it.

The zip object has a data field which holds the binary data.

I got the data now, but I cannot use it to create an image like this:

var img = new Image();
image.src = dataUrlFromJZip;

I'm relatively lost as to what I need to do. I know that the data cannot be used in it's current form, but I'm not sure what the solution is.

Any help is appreaciated


Solution

  • Have you tried

    var img = new Image();
    image.src = "data:image/png;base64," + dataUrlFromJZip;
    

    (replace png if necessary)