diff --git a/libs/omggif/omggif-worker.js b/libs/omggif/omggif-worker.js index d293031..9712ecd 100644 --- a/libs/omggif/omggif-worker.js +++ b/libs/omggif/omggif-worker.js @@ -90,7 +90,7 @@ self.onmessage = function(event) { addFrame( frames[i] ); self.postMessage({ type: "progress", - data: Math.round( (i+1)/framesLength*100 ) + data: (i+1)/framesLength }); } @@ -106,4 +106,7 @@ self.onmessage = function(event) { frameCount: framesLength, encodeTime: Math.round( (Date.now()-startTime)/10 ) / 100 }); + + // Terminate self + self.close(); }; \ No newline at end of file diff --git a/src/nodes/variable-animation.js b/src/nodes/variable-animation.js index 040b5f6..ff8817f 100644 --- a/src/nodes/variable-animation.js +++ b/src/nodes/variable-animation.js @@ -245,7 +245,7 @@ $(function(){ var self = this; gifWorker.addEventListener('message', function (e) { if (e.data.type === "progress") { - self.$(".status").text("GIF " + e.data.data + "% encoded..."); + self.$(".status").text("GIF " + Math.round(e.data.data*100) + "% encoded..."); } else if (e.data.type === "gif") { var gifurl = "data:image/gif;base64,"+window.btoa(e.data.data); var img = $('') @@ -253,7 +253,14 @@ $(function(){ src: gifurl, style: "max-width:100%" }); - self.$(".exports").prepend( "
" + e.data.frameCount + " frames encoded in " + e.data.encodeTime + " seconds
" ); + // Format file size + var fileSize = Math.round(e.data.data.length / 1024); + var fileSizeUnit = "kb"; + if (fileSize >= 1024) { + fileSize = Math.round(fileSize / 1024 * 10) / 10; + var fileSizeUnit = "mb"; + } + self.$(".exports").prepend( "
" + e.data.frameCount + " frames ("+fileSize+fileSizeUnit+") encoded in " + e.data.encodeTime + "s
" ); self.$(".exports").prepend( img ); self.$(".status").text(""); @@ -263,6 +270,7 @@ $(function(){ }, false); gifWorker.addEventListener('error', function (e) { self.$(".status").text("GIF encoding error :-("); + gifWorker.terminate(); }, false); // Send image data