Magnum::Trade::JpegImageConverter class

JPEG image converter plugin.

Creates JPEG (*.jpg, *.jpe, *.jpeg) files from images with format PixelFormat::R8Unorm or PixelFormat::RGB8Unorm. Images in PixelFormat::RGBA8Unorm are supported only if you use libJPEG Turbo instead of vanilla libJPEG and the alpha channel gets ignored (with a warning printed to the console). PixelFormat::RG8Unorm can't be easily supported, see StbImageConverter for an alternative with a possibility to export RG images as a grayscale JPEG.

This plugin depends on the Trade and libJPEG libraries and is built if WITH_JPEGIMAGECONVERTER is enabled when building Magnum Plugins. To use as a dynamic plugin, you need to load the "JpegImageConverter" plugin from MAGNUM_PLUGINS_IMAGECONVERTER_DIR. To use as a static plugin or as a dependency of another plugin with CMake, you need to request the JpegImageConverter component of the MagnumPlugins package and link to the MagnumPlugins::JpegImageConverter target. See Downloading and building plugins, Plugin usage with CMake and Loading and using plugins for more information.

libJPEG implementations

While some systems (such as macOS) still ship only with the vanilla libJPEG, you can get a much better performance and/or quality/size ratios by using other implementations:

  • libjpeg-turbo, optimized for compression and decompression speed, though not necessarily the best quality/size ratio
  • MozJPEG, optimized for quality/size ratio, though generally much slower than libjpeg-turbo

Plugin-specific config

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


# Compression quality (0 - 1, 1 is the best)

Base classes

class AbstractImageConverter
Base for image converter plugins.

Constructors, destructors, conversion operators

JpegImageConverter() explicit
Default constructor.
JpegImageConverter(PluginManager::AbstractManager& manager, std::string plugin) explicit
Plugin manager constructor.