Skip to main content

Build WasmEdge With WasmEdge-Image Plug-in

The WasmEdge Image plug-in is a software component that extends the functionality of the WasmEdge runtime, enabling it to load and decode JPEG and PNG images and convert them into tensors. This plug-in is useful for developers who need to process image data within their WebAssembly applications.

Prerequisites

The prerequisites of the WasmEdge-Image plug-in is the same as the WasmEdge building environment on the Linux platforms or MacOS platforms.

If developers build with their own environment, please ensure the zlib are installed.

sudo apt update
sudo apt install zlib1g-dev

On MacOS platforms, the libjpeg and libpng are required.

brew install jpeg-turbo libpng

Build WasmEdge with WasmEdge-Image Plug-in

To enable the WasmEdge WasmEdge-Image, developers need to building the WasmEdge from source with the cmake option -DWASMEDGE_PLUGIN_IMAGE=On.

cd <path/to/your/wasmedge/source/folder>
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_IMAGE=On
cmake --build build
# For the WasmEdge-Image plug-in, you should install this project.
cmake --install build
note

If the built wasmedge CLI tool cannot find the WasmEdge-Image plug-in, you can set the WASMEDGE_PLUGIN_PATH environment variable to the plug-in installation path (such as /usr/local/lib/wasmedge/, or the built plug-in path build/plugins/wasmedge_image/) to try to fix this issue.

Then you will have an executable wasmedge runtime under /usr/local/bin and the WasmEdge-Image plug-in under /usr/local/lib/wasmedge/libwasmedgePluginWasmEdgeImage.so after installation.

For more information, you can refer to the GitHub repository.