Magnum::Trade::WebPImageConverter class new in Git master

WebP image converter plugin.

Creates WebP (*.webp) images using the libwebp library. You can use WebPImporter to import images in this format.


This plugin depends on the Trade library and is built if MAGNUM_WITH_WEBPIMAGECONVERTER is enabled when building Magnum Plugins. To use as a dynamic plugin, load "WebPImageConverter" via Corrade::PluginManager::Manager.

Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-plugins repository and do the following. Using libwebp itself as a CMake subproject isn't tested at the moment, so you need to provide it as a system dependency and point CMAKE_PREFIX_PATH to its installation dir if necessary.

add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL)

# So the dynamically loaded plugin gets built implicitly
add_dependencies(your-app MagnumPlugins::WebPImageConverter)

To use as a static plugin or as a dependency of another plugin with CMake, put FindMagnumPlugins.cmake and FindWebP.cmake into your modules/ directory, request the WebPImageConverter component of the MagnumPlugins package and link to the MagnumPlugins::WebPImageConverter target:

find_package(MagnumPlugins REQUIRED WebPImageConverter)

# ...
target_link_libraries(your-app PRIVATE MagnumPlugins::WebPImageConverter)

See Downloading and building plugins, Plugin usage with CMake, Loading and using plugins and File format support for more information.

Behavior and limitations

Accepts 2D images in PixelFormat::RGB8Unorm and PixelFormat::RGBA8Unorm. The output is lossless by default, use the preset configuration option to choose a lossy preset instead.

The WebP file format doesn't have a way to distinguish between 2D and 1D array images. If an image has ImageFlag2D::Array set, a warning is printed and the file is saved as a regular 2D image.

The plugin recognizes ImageConverterFlag::Quiet, which will cause all conversion warnings to be suppressed.

Plugin-specific configuration

It's possible to tune various options through configuration(). See below for all options and their default values:

# Encoding preset. Possible values are:
#  - lossless -- lossless encoding
#  - default -- lossy encoding, not optimized for anything particular
#  - picture -- lossy, for digital pictures like portraits or indoor shots
#  - photo -- lossy, for outdoor photos with natural lighting
#  - drawing -- lossy, for hand or line drawings with high contrast details
#  - icon -- lossy, for small-size colorful images
#  - text -- lossy, for text-like content

# Lossless encoding preset. Used if preset is set to lossless, 0 is fastest
# with lowest compression and 9 is slowest with best compression.

# Lossy quality preset between 0 and 100.

# Preserve exact RGB values for transparent areas. If disabled, the invisible
# RGB information is discarded for better compression. If empty, exact values
# are preserved for the lossless preset and are discarded for lossy presets.
# Whether to use ARGB encoding instead of YUV. If empty, ARGB encoding is
# implicitly used for the lossless preset and YUV for lossy presets. Note
# that while it's possible to use YUV for a lossless encoding, the YUV
# conversion itself is lossy.
# Alpha quality between 0 and 100. If empty, it's set to 0 for RGB input and
# left at the library default (which is 100) for RGBA input.

See Editing plugin-specific configuration for more information and an example showing how to edit the configuration values.

Base classes

class AbstractImageConverter
Base for image converter plugins.

Constructors, destructors, conversion operators

WebPImageConverter(PluginManager::AbstractManager& manager, const Containers::StringView& plugin) explicit
Plugin manager constructor.