From 65be45c9796078ba31f7b0a162994c9d8051aa58 Mon Sep 17 00:00:00 2001 From: Georg Fischer Date: Sat, 28 Sep 2013 14:26:19 +0200 Subject: [PATCH] rip out re encoding code because it does not solve the problem. --- scripts/src/file.js | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/scripts/src/file.js b/scripts/src/file.js index f189a00..2a7577c 100644 --- a/scripts/src/file.js +++ b/scripts/src/file.js @@ -6,10 +6,6 @@ define( var reader; var feature; var allowed_file_types = [ 'image/png', 'image/jpg', 'image/jpeg' ]; - var re_encode = false; - var tmp_canvas = document.createElement( 'canvas' ); - var tmp_ctx = tmp_canvas.getContext( '2d' ); - var tmp_img = new Image(); function init( shared ) { @@ -32,49 +28,13 @@ define( allowed_file_types.indexOf( file.type ) !== -1 ) { - re_encode = false; - - // beware of ugly hack: - // jpg images can be progressive, in which case we need to - // convert them to to png to remove the progressive rendering. - // why? because i haven't figured out how to deal with - // progressive jpgs in the glitch logic yet - if ( allowed_file_types.indexOf( file.type ) > 0 ) - { - re_encode = true; - } - - reader.readAsDataURL( event.dataTransfer.files[0] ); + reader.readAsDataURL( file ); } } function fileLoaded( event ) { - var file_src = event.target.result; - - if ( re_encode ) - { - re_encode = false; - - reEncode( file_src, signals['set-new-src'].dispatch ); - } - - else - { - signals['set-new-src'].dispatch( file_src ); - } - } - - function reEncode( file_src, callback ) - { - tmp_img.onload = function() { - tmp_canvas.width = tmp_img.naturalWidth; - tmp_canvas.height = tmp_img.naturalHeight; - tmp_ctx.drawImage( tmp_img, 0, 0 ); - callback( tmp_canvas.toDataURL( 'image/png' ) ); - }; - - tmp_img.src = file_src; + signals['set-new-src'].dispatch( event.target.result ); } return { init: init };