diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-11-24 18:33:38 +0100 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-11-24 19:08:46 +0100 |
commit | 6939e4f12e9d5b6c69aa994bbd6fc4046f8941e5 (patch) | |
tree | 3426158247ae15786cb85b3f0cedc99d5735200a /src | |
parent | b9e801cb940b45cfd9a4cf95bf5af68b084156b4 (diff) |
Report if WebP is enabled and the version
Diffstat (limited to 'src')
-rw-r--r-- | src/dwebp.h | 1 | ||||
-rw-r--r-- | src/version.cc | 10 | ||||
-rw-r--r-- | src/webp.c | 19 |
3 files changed, 30 insertions, 0 deletions
diff --git a/src/dwebp.h b/src/dwebp.h index 930380b0..11718456 100644 --- a/src/dwebp.h +++ b/src/dwebp.h @@ -11,6 +11,7 @@ extern "C" { void *a_Webp_new(DilloImage *Image, DilloUrl *url, int version); void a_Webp_callback(int Op, void *data); +const char *a_Webp_version(char *buf, int n); #ifdef __cplusplus diff --git a/src/version.cc b/src/version.cc index 417a1807..f0dc9e93 100644 --- a/src/version.cc +++ b/src/version.cc @@ -21,6 +21,7 @@ #include "djpeg.h" #include "dpng.h" +#include "dwebp.h" #include "IO/tls.h" #include <FL/Fl.H> @@ -53,6 +54,10 @@ static void print_libs() printf(" png/%s", a_Png_version()); #endif +#ifdef ENABLE_WEBP + printf(" webp/%s", a_Webp_version(buf, 256)); +#endif + #ifdef ENABLE_TLS /* TLS prints the name/version format, as it determines which SSL * library is in use */ @@ -85,6 +90,11 @@ static void print_features() #else " -SVG" #endif +#ifdef ENABLE_WEBP + " +WEBP" +#else + " -WEBP" +#endif #if !( defined(DISABLE_XEMBED) || defined(WIN32) || defined(__APPLE__) ) " +XEMBED" #else @@ -2,6 +2,7 @@ * File: webp.c * * Copyright (C) 2024 dogma + * Copyright (C) 2024 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -172,6 +173,23 @@ void a_Webp_callback(int Op, void *data) } } +const char *a_Webp_version(char *buf, int n) +{ + /* Return the decoder's version number, packed in + * hexadecimal using 8bits for each of major/minor/revision. + * E.g: v2.5.7 is 0x020507. */ + int ver = WebPGetDecoderVersion(); + + int major = (ver >> 16) & 0xff; + int minor = (ver >> 8) & 0xff; + int rev = (ver >> 0) & 0xff; + + int k = snprintf(buf, n, "%d.%d.%d", major, minor, rev); + if (k >= n) + return "?"; + return buf; +} + /* * Create the image state data that must be kept between calls */ @@ -197,5 +215,6 @@ void *a_Webp_new(DilloImage *Image, DilloUrl *url, int version) void *a_Webp_new() { return 0; } void a_Webp_callback() { return; } +const char *a_Webp_version(char *buf, int n) { return NULL; } #endif /* ENABLE_WEBP */ |