Skip to content

Commit cdf0435

Browse files
author
Hector Martin
committed
Add support for different image types by specifying MIME type
1 parent 6a55f27 commit cdf0435

File tree

8 files changed

+428
-6
lines changed

8 files changed

+428
-6
lines changed

Diff for: README

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
== Introduction ==
22

33
zip_player is a JavaScript library to load and play back animated images
4-
packaged as an uncompressed ZIP archive containing individual PNG frames.
5-
Frames are drawn onto a Canvas element.
4+
packaged as an uncompressed ZIP archive containing individual frames.
5+
Frames are drawn onto a Canvas element and may be any image MIME type
6+
supported by the browser (e.g. JPEG, PNG, GIF - though animated GIFs are not
7+
supported for obvious reasons).
68

79
It also supports an unpacked mode where the images are directly referenced as
810
individual URLs (e.g. data: URLs for client-side preview purposes).
@@ -49,6 +51,6 @@ See the LICENSE file for full license text.
4951
Note: The license does not apply to third-party JavaScript and test images in
5052
the test/ directory. Those belong to their respective owners:
5153
- hon.zip and hon/ are public domain
52-
- big_buck_bunny.zip is licensed under CC-BY 3.0:
54+
- big_buck_bunny[_jpg].zip is licensed under CC-BY 3.0:
5355
(c) copyright 2008, Blender Foundation / www.bigbuckbunny.org
5456

Diff for: test/big_buck_bunny_jpg.zip

8.66 MB
Binary file not shown.

Diff for: test/hon_jpeg.zip

43.8 KB
Binary file not shown.

Diff for: test/index.html

+18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<script src="jquery-2.1.1.js"></script>
66
<script src="../zip_player.js"></script>
77
<script src="meta.js"></script>
8+
<script src="jpeg-meta.js"></script>
89
<script src="hon-meta.js"></script>
910
<style>
1011
#progress {
@@ -69,6 +70,18 @@
6970
$("#rewind").on("click", function() { p.rewind(); });
7071
$("#stop").on("click", function() { p.stop(); });
7172

73+
var options = {
74+
// no source: unzipped animation
75+
canvas: document.getElementById("canvasj"), // <canvas>
76+
source: "big_buck_bunny_jpg.zip",
77+
metadata: jpeg_meta, // TBD: json metadata format
78+
chunkSize: 300000,
79+
loop: true,
80+
autoStart: true,
81+
debug: true,
82+
}
83+
var pj = new ZipImagePlayer(options);
84+
7285
var options = {
7386
// no source: unzipped animation
7487
canvas: document.getElementById("canvas2"), // <canvas>
@@ -100,7 +113,12 @@
100113
<div id="load"></div>
101114
<div id="curframe"></div>
102115
<canvas id="canvas" width=320 height=180></canvas>
116+
(PNG)
117+
<br>
118+
<canvas id="canvasj" width=480 height=270></canvas>
119+
(JPEG)
103120
<br>
104121
<canvas id="canvas2" width=100 height=100></canvas>
122+
(PNG unpacked)
105123
</body>
106124
</html>

0 commit comments

Comments
 (0)