问题
I have a combination of client-side technologies creating PNG data in the browser. Is there a way to convert the PNG data to GIF for display in IE without sending the data to the server? Wondering if there is an existing JavaScript library that will parse the PNG data and output GIF, or even JPEG. I know that I can send the PNG data to a server and have PHP / Python / or whatever generate a file for display in IE, but I'm aiming to keep this all on the client side even if the processing of the image is somewhat slow.
UPDATE: No obvious existing JavaScript libraries to do this, so I'll use Flash to convert image data to GIF output for IE and continue to use PNG for all other browsers.
回答1:
Is it possible? I suppose. JavaScript is Turing-complete, and I suppose one might be able to get around browser restrictions by outputting an <img src="data: ..." />
sort of format.
Is it feasible or a good idea? Hell no. Doing this would be like needing some concrete and developing a Moon rocket to harvest lunar dust to make it instead of buying some at Home Depot.
回答2:
Hmm. Looks like some options have come out over the last couple of years:
- jsgif
mothereffinganimatedgif
png.js
回答3:
It seems that you have a Flash object that outputs PNG. Can you add a JPEG or GIF output option to it?
As an alternative, it seems there is a JavaScript library that enables PNG support in IE. Not sure how well it works, though.
来源:https://stackoverflow.com/questions/1263694/how-to-convert-png-to-gif-using-javascript-or-other-client-side-tech