SetModernImageCodecLibrary

Image handling, Configuration, Native codecs

Description

Sets the native MagickWand library file or directory used by modern image decoding

Syntax

Function TPDFlib.SetModernImageCodecLibrary(
  Const FileNameOrDirectory: WideString): Integer;

Parameters

FileNameOrDirectoryA full native library path or a directory containing the library and its dependencies

Return values

1The path was accepted before the codec module was loaded
0A codec module is already loaded and its path is immutable for the process lifetime

Remarks

Configure the path before calling ModernImageCodecAvailable or importing a modern image because either operation may load the module

If the argument is a portable library directory containing modules\coders, the loader supplies otherwise-unset MAGICK_HOME, MAGICK_CONFIGURE_PATH, and MAGICK_CODER_MODULE_PATH values for that process

When no explicit path is set, the loader checks PDFLIB_MODERN_IMAGE_CODEC, the executable directory, and platform library names

Applications may instead call RegisterModernImageDecoderBackend from PDFlibModernImage with a decoder callback that returns a fully oriented PNG stream

PDFlibModernImage unit functions

The PDFlibModernImage unit exposes the codec plumbing behind the methods above as standalone functions for applications that drive the decoder directly:

DetermineModernImageFormatSniffs a stream header and reports mifAVIF, mifHEIF, mifJPEGXL or mifUnknown
ModernImageFormatNameReturns the human-readable format name (AVIF, HEIF, JPEG XL or Unknown)
SetModernImageCodecLibraryPathUnit-level twin of this method; returns False once the codec module has already been loaded for the process
RegisterModernImageDecoderBackendInstalls a TPDFlibModernImageDecodeCallback that receives the input stream, the format, an ApplyOrientation flag and must write a fully oriented PNG stream; it takes precedence over the native codec module
ClearModernImageDecoderBackendRemoves a registered callback (equivalent to registering nil)
ModernImageCodecAvailableAttempts the one-time codec module load and reports whether native decoding is usable; the identically named TPDFlib method wraps this check
DecodeModernImageToPNGDecodes one image through the registered callback or, without one, through the native codec module; ApplyOrientation defaults to True

See also

ModernImageCodecAvailable, AddModernImageFromFile