Class WebPSupport
ImageIO: the pure-Java reader of TwelveMonkeys ImageIO (imageio-webp 3.15.3 and the five jars it needs, in com.iizix.core/lib/image), which runs on every architecture, so a WebP image is read on x86-64 and on ARM64 alike (a Mac with Apple silicon, Windows on ARM, Linux ARM64), in the server's JVM and in the Designer's. It replaces webp-imageio 0.1.6 (order 512), a JNI wrapper of libwebp 1.0.0 with an x86-64 native only, which order 486 had to leave out on ARM64.Registration. ImageIO's registry finds a reader through the service files of the jars on the class path of the thread that first touches it. On the server's plain class path that finds the reader; in the Designer's OSGi it does not (order 486 measured that the Designer's registry held no WebP reader at all: the service file lives inside the core bundle's class path, invisible to the thread that first touches the registry, and the TwelveMonkeys jars' own OSGi metadata needs a ServiceLoader mediator Eclipse does not carry). So SystemConfig's static initializer calls register() at core start: it registers the reader where the registry has none and does nothing where the service scan has found it. It calls it through registerAtStart(), which tells a class path without the plugin (one WARNING line) from a failure.
Reading only. IIZI reads WebP (a PWA icon or screenshot under a PNG or JPEG name, a profile picture, the favicon sources, thumbnailator) and never writes it: no WebP writer is registered, ImageIO.write(image,"webp",out) answers false and ImageIO.getImageWritersByMIMEType("image/webp") is empty - as it was in the Designer before. A writer is a decision of a later version (v5.3).
- Author:
- Christopher Mindus
Field Summary
FieldsMethod Summary
Modifier and TypeMethodDescriptionstatic booleanTells whether theIIORegistryholds the WebP reader now.static booleanTells whether a WebP writer is registered: false, IIZI writes no WebP (see the class comment).static booleanisWebP(byte[] head, int length) Tells whether the head of a file is a WebP image (the RIFF/WEBP signature).static intThe number of WebP readers of the plugin registered: 1 after core start.static booleanregister()Makes sure theIIORegistryholds the WebP reader: registers TwelveMonkeys'WebPImageReaderSpiwhen no provider of that class is registered, and does nothing when the registry's service scan has found it (or an earlier call registered it).static booleanCallsregister()at core start (SystemConfig's static initializer) and logs its failure: ONE line at WARNING when the TwelveMonkeys plugin is absent from the class path - a tool that loads the core without itslib/imagejars, such as the test load ofLicenseSystemBuilder: WebP images are then not read, and nothing else is wrong - naming "imageio-webp-3.15.3.jar" and the missing class; SEVERE with the stack for any other failure.static BooleanTells how the reader came into the registry at core start (the firstregister()): TRUE when that call registered it (the Designer's OSGi, where the service scan does not see the core bundle's jars), FALSE when the registry's service scan had found it already (a plain class path: the server), null whenregister()has not been called.
Field Details
MEDIA_TYPE
Method Details
register
public static boolean register()Makes sure theIIORegistryholds the WebP reader: registers TwelveMonkeys'WebPImageReaderSpiwhen no provider of that class is registered, and does nothing when the registry's service scan has found it (or an earlier call registered it). Called at core start bySystemConfig's static initializer; a later call registers the reader again only when it has been deregistered since.- Returns:
- true when this call registered the reader, false when the registry held it already.
registerAtStart
public static boolean registerAtStart()Callsregister()at core start (SystemConfig's static initializer) and logs its failure: ONE line at WARNING when the TwelveMonkeys plugin is absent from the class path - a tool that loads the core without itslib/imagejars, such as the test load ofLicenseSystemBuilder: WebP images are then not read, and nothing else is wrong - naming "imageio-webp-3.15.3.jar" and the missing class; SEVERE with the stack for any other failure. Never throws.- Returns:
- true when the call ended with the reader registered (by it or by the registry's service scan), false when it failed.
registeredAtStart
Tells how the reader came into the registry at core start (the firstregister()): TRUE when that call registered it (the Designer's OSGi, where the service scan does not see the core bundle's jars), FALSE when the registry's service scan had found it already (a plain class path: the server), null whenregister()has not been called.- Returns:
- The state, or null before core start.
hasReader
public static boolean hasReader()Tells whether theIIORegistryholds the WebP reader now.- Returns:
- true when a reader of the TwelveMonkeys WebP plugin is registered.
readerCount
public static int readerCount()The number of WebP readers of the plugin registered: 1 after core start.- Returns:
- The count.
hasWriter
public static boolean hasWriter()Tells whether a WebP writer is registered: false, IIZI writes no WebP (see the class comment).- Returns:
- true when any
ImageWriterSpiof the media typeimage/webpis registered.
isWebP
public static boolean isWebP(byte[] head, int length) Tells whether the head of a file is a WebP image (the RIFF/WEBP signature).- Parameters:
head- The first bytes of the file.length- The valid length ofhead.- Returns:
- true for a WebP image.