appetizermonster / tinygif

Gif Compression Service using WebAssembly
GNU General Public License v2.0
1 stars 0 forks source link

Is this your project in steemit? #1

Open shinebay opened 6 years ago

shinebay commented 6 years ago

Hello, I find this article in steemit: https://steemit.com/kr-dev/@heejin/c-c-webassembly, I guess this "tinygif" maybe refer to the article, but it doesn't has any compiled javascript in "tinygif", so I follow your article step by step(I am just a newbie in emscripten), but there are 2 problems:

  1. when the last step: # emcc src/gifsicle.bc -s WASM=1 -s "MODULARIZE=1" -s "EXPORT_NAME='Gifsicle'" -o src/gifsicle.js ,it give me the below WARNINGS: warning: unresolved symbol: posix_spawn_file_actions_adddup2 warning: unresolved symbol: posix_spawn_file_actions_destroy warning: unresolved symbol: posix_spawn_file_actions_init how can I solve it?
  2. <script type="text/javascript" src="./src/gifsicle.js"></script>
    <script type="text/javascript">
    var gifsicle = new Gifsicle();
    setTimeout(function() {
      // Gifsicle 내부적으로 .wasm 파일을 다운로드하기 때문에 약간의 시간을 기다린 후,
      // gifsicle 오브젝트를 사용할 수 있습니다.
    }, 1000);
    </script>

    what is code in setTimeout function? can you give us some demo code? thank you very much:)

appetizermonster commented 6 years ago

Yes this repo is what you found in the steemit post. But I'm not actively studying WebAssembly anymore, I can't give you the answer for the first question, sorry. The answer for the second question is that you need to wait few milliseconds before using Gifsicle class. Because Gifsicle class downloads(fetch) wasm file in async manner internally. Thank you

shinebay commented 6 years ago

@appetizermonster thank you for your instant reply, I just wonder how can I pass the parameters to gifsicile.js?

var gifsicle = new Gifsicle(reader.result,{arguments:['-O3','--lossy=80']});

but it doesn't compress the gif, only output the original gif without any compression

appetizermonster commented 6 years ago

I remembered that I modified c source file and inserted hard-coded arguments in the source file. and it worked.

FYI, the WebAssembly version of Gifsicle was very slow when I built, because Gifsicle is using recursive call very intensively but recursive call is very slow in WebAssembly for now.