README.webp_js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. __ __ ____ ____ ____ __ ____
  2. / \\/ \ _ \ _ \ _ \ (__)/ __\
  3. \ / __/ _ \ __/ _) \_ \
  4. \__\__/_____/____/_/ /____/____/
  5. Description:
  6. ============
  7. This file describes the compilation of libwebp into a JavaScript decoder
  8. using Emscripten and CMake.
  9. - install the Emscripten SDK following the procedure described at:
  10. https://emscripten.org/docs/getting_started/downloads.html#installation-instructions-using-the-emsdk-recommended
  11. After installation, you should have some global variable positioned to the
  12. location of the SDK. In particular, $EMSDK should point to the
  13. top-level directory containing Emscripten tools.
  14. - configure the project 'WEBP_JS' with CMake using:
  15. cd webp_js && \
  16. emcmake cmake -DWEBP_BUILD_WEBP_JS=ON \
  17. ../
  18. - compile webp.js using 'emmake make'.
  19. - that's it! Upon completion, you should have the webp.js and
  20. webp.wasm files generated.
  21. The callable JavaScript function is WebPToSDL(), which decodes a raw WebP
  22. bitstream into a canvas. See webp_js/index.html for a simple usage sample
  23. (see below for instructions).
  24. Demo HTML page:
  25. ===============
  26. The HTML page webp_js/index.html requires an HTTP server to serve the WebP
  27. image example. It's easy to just use Python for that.
  28. cd webp_js && python -m SimpleHTTPServer 8080
  29. and then navigate to http://localhost:8080 in your favorite browser.
  30. Web-Assembly (WASM) version:
  31. ============================
  32. CMakeLists.txt is configured to build the WASM version when using
  33. the option WEBP_BUILD_WEBP_JS=ON. The compilation step will assemble
  34. the files 'webp_wasm.js', 'webp_wasm.wasm' in the webp_js/ directory.
  35. See webp_js/index_wasm.html for a simple demo page using the WASM version
  36. of the library.
  37. You will need a fairly recent version of Emscripten (at least 2.0.18,
  38. latest-upstream is recommended) and of your WASM-enabled browser to run this
  39. version.
  40. Caveat:
  41. =======
  42. - First decoding using the library is usually slower, due to just-in-time
  43. compilation.
  44. - Some versions of llvm produce the following compile error when SSE2 is
  45. enabled.
  46. "Unsupported: %516 = bitcast <8 x i16> %481 to i128
  47. LLVM ERROR: BitCast Instruction not yet supported for integer types larger than 64 bits"
  48. The corresponding Emscripten bug is at:
  49. https://github.com/kripken/emscripten/issues/3788
  50. Therefore, SSE2 optimization is currently disabled in CMakeLists.txt.
  51. - If WEBP_ENABLE_SIMD is set to 1 the JavaScript version (webp.js) will be
  52. disabled as wasm2js does not support SIMD.