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.

Usage

This plugin depends on the Trade and libwebp libraries 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 and libwebp repositories and do the following. If you want to use system-installed libwebp, omit the first part and point CMAKE_PREFIX_PATH to its installation dir if necessary.

# Build libwebp as static to have the plugin self-contained
set(WEBP_LINK_STATIC ON CACHE BOOL "" FORCE)
# Disable unneeded functionality
set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_CWEBP OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_DWEBP OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_GIF2WEBP OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_IMG2WEBP OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_VWEBP OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_WEBPINFO OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_LIBWEBPMUX OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_WEBPMUX OFF CACHE BOOL "" FORCE)
set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "" FORCE)
add_subdirectory(libwebp EXCLUDE_FROM_ALL)

set(MAGNUM_WITH_WEBPIMAGECONVERTER ON CACHE BOOL "" FORCE)
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, 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:

[configuration]
# 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
preset=lossless

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

# Lossy quality preset between 0 and 100.
lossy=75.0

# 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.
exactTransparentRgb=
# 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.
useArgb=
# 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.
alphaQuality=

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.