Skip to content
Serverless Image Resizing on Apache OpenWhisk using WebAssembly
C JavaScript Makefile
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead, 4 commits behind cloudflare:master.
Latest commit 5e860a8 Jul 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
stb @ e6afb9c Initial commit. Sep 28, 2018
stubs Initial commit. Sep 28, 2018
.gitignore Porting Cloudflare Workers example to Apache OpenWhisk Jul 29, 2019
.gitmodules Initial commit. Sep 28, 2018
LICENSE Initial commit. Sep 28, 2018
Makefile Porting Cloudflare Workers example to Apache OpenWhisk Jul 29, 2019
README.md
bootstrap.h Initial commit. Sep 28, 2018
main.c
package.json Porting Cloudflare Workers example to Apache OpenWhisk Jul 29, 2019
resizer.wasm Porting Cloudflare Workers example to Apache OpenWhisk Jul 29, 2019
worker.js Porting Cloudflare Workers example to Apache OpenWhisk Jul 29, 2019

README.md

Apache OpenWhisk Image Resizing with WebAssembly

This repository contains a serverless function (for Apache OpenWhisk) to resize images using a C library called via WebAssembly. It is a fork of original code created by Cloudflare for their Workers platform. See the original repository for details on what the repository contains and how the files work.

Usage

  • Create deployment package from source files.
zip action.zip resizer.wasm package.json worker.js
  • Create Apache OpenWhisk action from deployment package.
ibmcloud wsk action update resizer action.zip --kind nodejs:10 --web true
  • Retrieve HTTP URL for Web Action.
ibmcloud wsk action get resizer --url
ok: got action resizer
https://<region>.cloud.ibm.com/api/v1/web/<ns>/default/resizer <-- USE THIS URL
  • Open the HTTP URL with the .http extension.
https://<region>.cloud.ibm.com/api/v1/web/<ns>/default/resizer.http

This should return the following image resized to 250 pixels (from 900 pixels).

Pug with Ice-cream

URL query parameters (url and width) can be used to modify the image source or output width for the next image, e.g.

https://<region>.cloud.ibm.com/api/v1/web/<ns>/default/resizer.http?url=<IMG_URL>&width=500

How to re-build WASM file (OS X)

  • Install LLVM.
brew install llvm
brew link --force llvm
  • Remove existing WASM file (resize.wasm)
make clean
  • Run build command (which uses clang).
make build
You can’t perform that action at this time.