Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extract a image file from a zip file, and convert it to DataURL format? #213

Open
microkof opened this issue May 6, 2015 · 5 comments

Comments

@microkof
Copy link

microkof commented May 6, 2015

I think maybe zipEntry.asBinary() and zipEntry.asArrayBuffer() are close to the correct answer, but I don't think them is the correct answer.
What can I use?
Thanks for answer!

@Mithgol
Copy link
Contributor

Mithgol commented May 7, 2015

You may try my Dauria package. However, it uses Node.js Buffer as a source; therefore, if your work resides in a web browser, some browser-based Buffer implementation becomes necessary (such as the implementation provided by Browserify).

@microkof
Copy link
Author

microkof commented May 8, 2015

thank you, but I want to use Jszip in modern web browser, not Node.js.

@Stuk
Copy link
Owner

Stuk commented May 31, 2015

Here is a JSFiddle that converts an array buffer to a data URL and sets it as the source of an image: http://jsfiddle.net/Jan_Miksovsky/yy7Zs/

@ottoville
Copy link

URL.createObjectURL(new Blob([zip.file('filename').asArrayBuffer()], {type : your/mime'}))

@mdaynul
Copy link

mdaynul commented Apr 15, 2016

thanks @ottoville it worked nice!
.. i have to rely on extracting "extenstion" to prepare "mimeType" from filename, and its surely not a good point.
@Stuk how to get mimeType of any file included in zipped content?
I feel, in the API doc you provided, there are plenty of examples for making the zipped file, still working with unzipped contents has no useful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants