SDL_image: Removed IMG_Init() and IMG_Quit()

From f389281808c612cacef1d56a749448f9abce86c5 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 2 Dec 2024 16:06:11 -0800
Subject: [PATCH] Removed IMG_Init() and IMG_Quit()

IMG_Init() and IMG_Quit() are no longer necessary. If an image format requires dynamically loading a support library, that will be done automatically.
---
 cmake/test/main.c              |  19 +------
 docs/README-migration.md       |   6 ++
 include/SDL3_image/SDL_image.h | 101 ---------------------------------
 src/IMG.c                      |  65 ---------------------
 src/IMG.h                      |  38 -------------
 src/IMG_ImageIO.m              |  36 ------------
 src/IMG_WIC.c                  |  41 ++-----------
 src/IMG_avif.c                 |  29 ++++------
 src/IMG_bmp.c                  |   1 -
 src/IMG_gif.c                  |   1 -
 src/IMG_jpg.c                  |  36 +++---------
 src/IMG_jxl.c                  |  25 +++-----
 src/IMG_lbm.c                  |   1 -
 src/IMG_pcx.c                  |   1 -
 src/IMG_png.c                  |  36 +++---------
 src/IMG_pnm.c                  |   1 -
 src/IMG_qoi.c                  |   1 -
 src/IMG_stb.c                  |   1 -
 src/IMG_svg.c                  |   1 -
 src/IMG_tga.c                  |   1 -
 src/IMG_tif.c                  |  23 +++-----
 src/IMG_webp.c                 |  33 ++++-------
 src/IMG_xcf.c                  |   1 -
 src/IMG_xpm.c                  |   1 -
 src/IMG_xv.c                   |   1 -
 src/IMG_xxx.c                  |   1 -
 src/SDL_image.sym              |   2 -
 test/main.c                    |  56 ------------------
 28 files changed, 66 insertions(+), 493 deletions(-)
 create mode 100644 docs/README-migration.md
 delete mode 100644 src/IMG.h

diff --git a/cmake/test/main.c b/cmake/test/main.c
index 8eb21937..0b57b50e 100644
--- a/cmake/test/main.c
+++ b/cmake/test/main.c
@@ -2,22 +2,6 @@
 #include <SDL3/SDL_main.h>
 #include <SDL3_image/SDL_image.h>
 
-#define TEST_INIT_FLAG(FLAG) do {                   \
-        if ((IMG_Init(FLAG) & FLAG) == FLAG) {      \
-            SDL_Log("IMG_Init("#FLAG") succeeded"); \
-        } else {                                    \
-            SDL_Log("IMG_Init("#FLAG") failed");    \
-        }                                           \
-    } while (0);
-
-#define FOREACH_INIT_FLAGS(X) \
-    X(IMG_INIT_JPG)           \
-    X(IMG_INIT_PNG)           \
-    X(IMG_INIT_TIF)           \
-    X(IMG_INIT_WEBP)          \
-    X(IMG_INIT_JXL)           \
-    X(IMG_INIT_AVIF)          \
-
 int main(int argc, char *argv[])
 {
     if (!SDL_Init(0)) {
@@ -25,9 +9,8 @@ int main(int argc, char *argv[])
         return 1;
     }
 
-    FOREACH_INIT_FLAGS(TEST_INIT_FLAG)
+    IMG_Version();
 
-    IMG_Quit();
     SDL_Quit();
     return 0;
 }
diff --git a/docs/README-migration.md b/docs/README-migration.md
new file mode 100644
index 00000000..56b690c1
--- /dev/null
+++ b/docs/README-migration.md
@@ -0,0 +1,6 @@
+
+# Migrating to SDL_image 3.0
+
+This guide provides useful information for migrating applications from SDL_image 2.0 to SDL_image 3.0.
+
+IMG_Init() and IMG_Quit() are no longer necessary. If an image format requires dynamically loading a support library, that will be done automatically.
diff --git a/include/SDL3_image/SDL_image.h b/include/SDL3_image/SDL_image.h
index e5ff0835..ae1fd347 100644
--- a/include/SDL3_image/SDL_image.h
+++ b/include/SDL3_image/SDL_image.h
@@ -67,107 +67,6 @@ extern "C" {
  */
 extern SDL_DECLSPEC int SDLCALL IMG_Version(void);
 
-/**
- * Initialization flags
- */
-typedef Uint32 IMG_InitFlags;
-
-#define IMG_INIT_JPG    0x00000001
-#define IMG_INIT_PNG    0x00000002
-#define IMG_INIT_TIF    0x00000004
-#define IMG_INIT_WEBP   0x00000008
-#define IMG_INIT_JXL    0x00000010
-#define IMG_INIT_AVIF   0x00000020
-
-/**
- * Initialize SDL_image.
- *
- * This function loads dynamic libraries that SDL_image needs, and prepares
- * them for use. This must be the first function you call in SDL_image, and if
- * it fails you should not continue with the library.
- *
- * Flags should be one or more flags from IMG_InitFlags OR'd together. It
- * returns the flags successfully initialized, or 0 on failure.
- *
- * Currently, these flags are:
- *
- * - `IMG_INIT_JPG`
- * - `IMG_INIT_PNG`
- * - `IMG_INIT_TIF`
- * - `IMG_INIT_WEBP`
- * - `IMG_INIT_JXL`
- * - `IMG_INIT_AVIF`
- *
- * More flags may be added in a future SDL_image release.
- *
- * This function may need to load external shared libraries to support various
- * codecs, which means this function can fail to initialize that support on an
- * otherwise-reasonable system if the library isn't available; this is not
- * just a question of exceptional circumstances like running out of memory at
- * startup!
- *
- * Note that you may call this function more than once to initialize with
- * additional flags. The return value will reflect both new flags that
- * successfully initialized, and also include flags that had previously been
- * initialized as well.
- *
- * As this will return previously-initialized flags, it's legal to call this
- * with zero (no flags set). This is a safe no-op that can be used to query
- * the current initialization state without changing it at all.
- *
- * Since this returns previously-initialized flags as well as new ones, and
- * you can call this with zero, you should not check for a zero return value
- * to determine an error condition. Instead, you should check to make sure all
- * the flags you require are set in the return value. If you have a game with
- * data in a specific format, this might be a fatal error. If you're a generic
- * image displaying app, perhaps you are fine with only having JPG and PNG
- * support and can live without WEBP, even if you request support for
- * everything.
- *
- * Unlike other SDL satellite libraries, calls to IMG_Init do not stack; a
- * single call to IMG_Quit() will deinitialize everything and does not have to
- * be paired with a matching IMG_Init call. For that reason, it's considered
- * best practices to have a single IMG_Init and IMG_Quit call in your program.
- * While this isn't required, be aware of the risks of deviating from that
- * behavior.
- *
- * After initializing SDL_image, the app may begin to load images into
- * SDL_Surfaces or SDL_Textures.
- *
- * \param flags initialization flags, OR'd together.
- * \returns all currently initialized flags.
- *
- * \since This function is available since SDL_image 3.0.0.
- *
- * \sa IMG_Quit
- */
-extern SDL_DECLSPEC IMG_InitFlags SDLCALL IMG_Init(IMG_InitFlags flags);
-
-/**
- * Deinitialize SDL_image.
- *
- * This should be the last function you call in SDL_image, after freeing all
- * other resources. This will unload any shared libraries it is using for
- * various codecs.
- *
- * After this call, a call to IMG_Init(0) will return 0 (no codecs loaded).
- *
- * You can safely call IMG_Init() to reload various codec support after this
- * call.
- *
- * Unlike other SDL satellite libraries, calls to IMG_Init do not stack; a
- * single call to IMG_Quit() will deinitialize everything and does not have to
- * be paired with a matching IMG_Init call. For that reason, it's considered
- * best practices to have a single IMG_Init and IMG_Quit call in your program.
- * While this isn't required, be aware of the risks of deviating from that
- * behavior.
- *
- * \since This function is available since SDL_image 3.0.0.
- *
- * \sa IMG_Init
- */
-extern SDL_DECLSPEC void SDLCALL IMG_Quit(void);
-
 /**
  * Load an image from an SDL data source into a software surface.
  *
diff --git a/src/IMG.c b/src/IMG.c
index b32adc33..1b4de2a5 100644
--- a/src/IMG.c
+++ b/src/IMG.c
@@ -22,7 +22,6 @@
 /* A simple library to load images of various formats as SDL surfaces */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef __EMSCRIPTEN__
 #include <emscripten/emscripten.h>
@@ -89,70 +88,6 @@ int IMG_Version(void)
     return SDL_IMAGE_VERSION;
 }
 
-static IMG_InitFlags initialized = 0;
-
-IMG_InitFlags IMG_Init(IMG_InitFlags flags)
-{
-    IMG_InitFlags result = 0;
-
-    if (flags & IMG_INIT_AVIF) {
-        if ((initialized & IMG_INIT_AVIF) || IMG_InitAVIF() == 0) {
-            result |= IMG_INIT_AVIF;
-        }
-    }
-    if (flags & IMG_INIT_JPG) {
-        if ((initialized & IMG_INIT_JPG) || IMG_InitJPG() == 0) {
-            result |= IMG_INIT_JPG;
-        }
-    }
-    if (flags & IMG_INIT_JXL) {
-        if ((initialized & IMG_INIT_JXL) || IMG_InitJXL() == 0) {
-            result |= IMG_INIT_JXL;
-        }
-    }
-    if (flags & IMG_INIT_PNG) {
-        if ((initialized & IMG_INIT_PNG) || IMG_InitPNG() == 0) {
-            result |= IMG_INIT_PNG;
-        }
-    }
-    if (flags & IMG_INIT_TIF) {
-        if ((initialized & IMG_INIT_TIF) || IMG_InitTIF() == 0) {
-            result |= IMG_INIT_TIF;
-        }
-    }
-    if (flags & IMG_INIT_WEBP) {
-        if ((initialized & IMG_INIT_WEBP) || IMG_InitWEBP() == 0) {
-            result |= IMG_INIT_WEBP;
-        }
-    }
-    initialized |= result;
-
-    return initialized;
-}
-
-void IMG_Quit(void)
-{
-    if (initialized & IMG_INIT_AVIF) {
-        IMG_QuitAVIF();
-    }
-    if (initialized & IMG_INIT_JPG) {
-        IMG_QuitJPG();
-    }
-    if (initialized & IMG_INIT_JXL) {
-        IMG_QuitJXL();
-    }
-    if (initialized & IMG_INIT_PNG) {
-        IMG_QuitPNG();
-    }
-    if (initialized & IMG_INIT_TIF) {
-        IMG_QuitTIF();
-    }
-    if (initialized & IMG_INIT_WEBP) {
-        IMG_QuitWEBP();
-    }
-    initialized = 0;
-}
-
 #if !defined(__APPLE__) || defined(SDL_IMAGE_USE_COMMON_BACKEND)
 /* Load an image from a file */
 SDL_Surface *IMG_Load(const char *file)
diff --git a/src/IMG.h b/src/IMG.h
deleted file mode 100644
index 02208d5c..00000000
--- a/src/IMG.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-  SDL_image:  An example image loading library for use with SDL
-  Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-
-#ifndef SDLIMAGE_IMG_H
-#define SDLIMAGE_IMG_H
-
-extern int IMG_InitAVIF(void);
-extern void IMG_QuitAVIF(void);
-extern int IMG_InitJPG(void);
-extern void IMG_QuitJPG(void);
-extern int IMG_InitJXL(void);
-extern void IMG_QuitJXL(void);
-extern int IMG_InitPNG(void);
-extern void IMG_QuitPNG(void);
-extern int IMG_InitTIF(void);
-extern void IMG_QuitTIF(void);
-extern int IMG_InitWEBP(void);
-extern void IMG_QuitWEBP(void);
-
-#endif
diff --git a/src/IMG_ImageIO.m b/src/IMG_ImageIO.m
index 1096210f..43343ce5 100644
--- a/src/IMG_ImageIO.m
+++ b/src/IMG_ImageIO.m
@@ -10,7 +10,6 @@
 #if defined(__APPLE__) && !defined(SDL_IMAGE_USE_COMMON_BACKEND)
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 // Used because CGDataProviderCreate became deprecated in 10.5
 #include <AvailabilityMacros.h>
@@ -357,41 +356,6 @@ static CFDictionaryRef CreateHintDictionary(CFStringRef uti_string_hint)
 }
 
 
-#ifdef JPG_USES_IMAGEIO
-
-int IMG_InitJPG(void)
-{
-    return 0;
-}
-
-void IMG_QuitJPG(void)
-{
-}
-
-#endif /* JPG_USES_IMAGEIO */
-
-#ifdef PNG_USES_IMAGEIO
-
-int IMG_InitPNG(void)
-{
-    return 0;
-}
-
-void IMG_QuitPNG(void)
-{
-}
-
-#endif /* PNG_USES_IMAGEIO */
-
-int IMG_InitTIF(void)
-{
-    return 0;
-}
-
-void IMG_QuitTIF(void)
-{
-}
-
 static bool Internal_isType (SDL_IOStream *rw_ops, CFStringRef uti_string_to_test)
 {
     bool is_type = false;
diff --git a/src/IMG_WIC.c b/src/IMG_WIC.c
index a4762144..36649efe 100644
--- a/src/IMG_WIC.c
+++ b/src/IMG_WIC.c
@@ -22,14 +22,13 @@
 #if defined(SDL_IMAGE_USE_WIC_BACKEND)
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 #define COBJMACROS
 #include <initguid.h>
 #include <wincodec.h>
 
 static IWICImagingFactory* wicFactory = NULL;
 
-static int WIC_Init(void)
+static bool WIC_Init(void)
 {
     if (wicFactory == NULL) {
         HRESULT hr = CoCreateInstance(
@@ -40,49 +39,21 @@ static int WIC_Init(void)
             (void**)&wicFactory
         );
         if (FAILED(hr)) {
-            return -1;
+            return false;
         }
     }
 
-    return 0;
+    return true;
 }
 
+#if 0
 static void WIC_Quit(void)
 {
     if (wicFactory) {
         IWICImagingFactory_Release(wicFactory);
     }
 }
-
-int IMG_InitPNG(void)
-{
-    return WIC_Init();
-}
-
-void IMG_QuitPNG(void)
-{
-    WIC_Quit();
-}
-
-int IMG_InitJPG(void)
-{
-    return WIC_Init();
-}
-
-void IMG_QuitJPG(void)
-{
-    WIC_Quit();
-}
-
-int IMG_InitTIF(void)
-{
-    return WIC_Init();
-}
-
-void IMG_QuitTIF(void)
-{
-    WIC_Quit();
-}
+#endif // 0
 
 bool IMG_isPNG(SDL_IOStream *src)
 {
@@ -214,7 +185,7 @@ static SDL_Surface* WIC_LoadImage(SDL_IOStream *src)
     IWICFormatConverter* formatConverter = NULL;
     UINT width, height;
 
-    if (wicFactory == NULL && (WIC_Init() < 0)) {
+    if (!WIC_Init()) {
         SDL_SetError("WIC failed to initialize!");
         return NULL;
     }
diff --git a/src/IMG_avif.c b/src/IMG_avif.c
index 96e1ca5b..ec4035c6 100644
--- a/src/IMG_avif.c
+++ b/src/IMG_avif.c
@@ -22,7 +22,6 @@
 /* This is a AVIF image file loading framework */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 /* We'll have AVIF save support by default */
 #if !defined(SDL_IMAGE_SAVE_AVIF)
@@ -77,24 +76,24 @@ static struct {
 #ifdef LOAD_AVIF_DYNAMIC
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = (SIG) SDL_LoadFunction(lib.handle, #FUNC); \
-    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return -1; }
+    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return false; }
 #else
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = FUNC; \
-    if (lib.FUNC == NULL) { SDL_SetError("Missing avif.framework"); return -1; }
+    if (lib.FUNC == NULL) { return SDL_SetError("Missing avif.framework"); }
 #endif
 
 #ifdef __APPLE__
     /* Need to turn off optimizations so weak framework load check works */
     __attribute__ ((optnone))
 #endif
-int IMG_InitAVIF(void)
+static bool IMG_InitAVIF(void)
 {
     if ( lib.loaded == 0 ) {
 #ifdef LOAD_AVIF_DYNAMIC
         lib.handle = SDL_LoadObject(LOAD_AVIF_DYNAMIC);
         if ( lib.handle == NULL ) {
-            return -1;
+            return false;
         }
 #endif
         FUNCTION_LOADER(avifDecoderCreate, avifDecoder * (*)(void))
@@ -117,8 +116,9 @@ int IMG_InitAVIF(void)
     }
     ++lib.loaded;
 
-    return 0;
+    return true;
 }
+#if 0
 void IMG_QuitAVIF(void)
 {
     if ( lib.loaded == 0 ) {
@@ -131,6 +131,7 @@ void IMG_QuitAVIF(void)
     }
     --lib.loaded;
 }
+#endif // 0
 
 static bool ReadAVIFHeader(SDL_IOStream *src, Uint8 **header_data, size_t *header_size)
 {
@@ -211,7 +212,7 @@ bool IMG_isAVIF(SDL_IOStream *src)
     is_AVIF = false;
     if (ReadAVIFHeader(src, &data, &size)) {
         /* This might be AVIF, do more thorough checks */
-        if ((IMG_Init(IMG_INIT_AVIF) & IMG_INIT_AVIF) != 0) {
+        if (IMG_InitAVIF()) {
             avifROData header;
 
             header.data = data;
@@ -365,7 +366,7 @@ SDL_Surface *IMG_LoadAVIF_IO(SDL_IOStream *src)
     }
     start = SDL_TellIO(src);
 
-    if ((IMG_Init(IMG_INIT_AVIF) & IMG_INIT_AVIF) == 0) {
+    if (!IMG_InitAVIF()) {
         return NULL;
     }
 
@@ -532,7 +533,7 @@ static bool IMG_SaveAVIF_IO_libavif(SDL_Surface *surface, SDL_IOStream *dst, int
     SDL_PropertiesID props;
     bool result = false;
 
-    if (!IMG_Init(IMG_INIT_AVIF)) {
+    if (!IMG_InitAVIF()) {
         return false;
     }
 
@@ -710,16 +711,6 @@ static bool IMG_SaveAVIF_IO_libavif(SDL_Surface *surface, SDL_IOStream *dst, int
 #pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
 #endif
 
-int IMG_InitAVIF(void)
-{
-    SDL_SetError("AVIF images are not supported");
-    return -1;
-}
-
-void IMG_QuitAVIF(void)
-{
-}
-
 /* See if an image is contained in a data source */
 bool IMG_isAVIF(SDL_IOStream *src)
 {
diff --git a/src/IMG_bmp.c b/src/IMG_bmp.c
index 4386896a..18ef6adb 100644
--- a/src/IMG_bmp.c
+++ b/src/IMG_bmp.c
@@ -31,7 +31,6 @@
  */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_BMP
 
diff --git a/src/IMG_gif.c b/src/IMG_gif.c
index 4825eec9..06858f6f 100644
--- a/src/IMG_gif.c
+++ b/src/IMG_gif.c
@@ -22,7 +22,6 @@
 /* This is a GIF image file loading framework */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_GIF
 
diff --git a/src/IMG_jpg.c b/src/IMG_jpg.c
index d7a3e05f..b6f408fd 100644
--- a/src/IMG_jpg.c
+++ b/src/IMG_jpg.c
@@ -22,7 +22,6 @@
 /* This is a JPEG image file loading framework */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #include <stdio.h>
 #include <setjmp.h>
@@ -89,19 +88,19 @@ static struct {
 #ifdef LOAD_JPG_DYNAMIC
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = (SIG) SDL_LoadFunction(lib.handle, #FUNC); \
-    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return -1; }
+    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return false; }
 #else
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = FUNC;
 #endif
 
-int IMG_InitJPG(void)
+static bool IMG_InitJPG(void)
 {
     if ( lib.loaded == 0 ) {
 #ifdef LOAD_JPG_DYNAMIC
         lib.handle = SDL_LoadObject(LOAD_JPG_DYNAMIC);
         if ( lib.handle == NULL ) {
-            return -1;
+            return false;
         }
 #endif
         FUNCTION_LOADER(jpeg_calc_output_dimensions, void (*) (j_decompress_ptr cinfo))
@@ -123,8 +122,9 @@ int IMG_InitJPG(void)
     }
     ++lib.loaded;
 
-    return 0;
+    return true;
 }
+#if 0
 void IMG_QuitJPG(void)
 {
     if ( lib.loaded == 0 ) {
@@ -137,6 +137,7 @@ void IMG_QuitJPG(void)
     }
     --lib.loaded;
 }
+#endif // 0
 
 /* See if an image is contained in a data source */
 bool IMG_isJPG(SDL_IOStream *src)
@@ -357,7 +358,7 @@ SDL_Surface *IMG_LoadJPG_IO(SDL_IOStream *src)
     }
     start = SDL_TellIO(src);
 
-    if ( (IMG_Init(IMG_INIT_JPG) & IMG_INIT_JPG) == 0 ) {
+    if (!IMG_InitJPG()) {
         return NULL;
     }
 
@@ -538,7 +539,7 @@ static bool IMG_SaveJPG_IO_jpeglib(SDL_Surface *surface, SDL_IOStream *dst, int
     SDL_Surface* jpeg_surface = surface;
     bool result;
 
-    if (!IMG_Init(IMG_INIT_JPG)) {
+    if (!IMG_InitJPG()) {
         return false;
     }
 
@@ -563,17 +564,6 @@ static bool IMG_SaveJPG_IO_jpeglib(SDL_Surface *surface, SDL_IOStream *dst, int
 
 extern SDL_Surface *IMG_LoadSTB_IO(SDL_IOStream *src);
 
-int IMG_InitJPG(void)
-{
-    /* Nothing to load */
-    return 0;
-}
-
-void IMG_QuitJPG(void)
-{
-    /* Nothing to unload */
-}
-
 /* FIXME: This is a copypaste from JPEGLIB! Pull that out of the ifdefs */
 /* Define this for quicker (but less perfect) JPEG identification */
 #define FAST_IS_JPEG
@@ -659,16 +649,6 @@ SDL_Surface *IMG_LoadJPG_IO(SDL_IOStream *src)
 #pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
 #endif
 
-int IMG_InitJPG(void)
-{
-    SDL_SetError("JPEG images are not supported");
-    return -1;
-}
-
-void IMG_QuitJPG(void)
-{
-}
-
 /* See if an image is contained in a data source */
 bool IMG_isJPG(SDL_IOStream *src)
 {
diff --git a/src/IMG_jxl.c b/src/IMG_jxl.c
index 0c5c91c1..e193019e 100644
--- a/src/IMG_jxl.c
+++ b/src/IMG_jxl.c
@@ -22,7 +22,6 @@
 /* This is a JXL image file loading framework */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_JXL
 
@@ -45,24 +44,24 @@ static struct {
 #ifdef LOAD_JXL_DYNAMIC
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = (SIG) SDL_LoadFunction(lib.handle, #FUNC); \
-    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return -1; }
+    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return false; }
 #else
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = FUNC; \
-    if (lib.FUNC == NULL) { SDL_SetError("Missing jxl.framework"); return -1; }
+    if (lib.FUNC == NULL) { return SDL_SetError("Missing jxl.framework"); }
 #endif
 
 #ifdef __APPLE__
     /* Need to turn off optimizations so weak framework load check works */
     __attribute__ ((optnone))
 #endif
-int IMG_InitJXL(void)
+static bool IMG_InitJXL(void)
 {
     if ( lib.loaded == 0 ) {
 #ifdef LOAD_JXL_DYNAMIC
         lib.handle = SDL_LoadObject(LOAD_JXL_DYNAMIC);
         if ( lib.handle == NULL ) {
-            return -1;
+            return false;
         }
 #endif
         FUNCTION_LOADER(JxlDecoderCreate, JxlDecoder* (*)(const JxlMemoryManager* memory_manager))
@@ -76,8 +75,9 @@ int IMG_InitJXL(void)
     }
     ++lib.loaded;
 
-    return 0;
+    return true;
 }
+#if 0
 void IMG_QuitJXL(void)
 {
     if ( lib.loaded == 0 ) {
@@ -90,6 +90,7 @@ void IMG_QuitJXL(void)
     }
     --lib.loaded;
 }
+#endif // 0
 
 /* See if an image is contained in a data source */
 bool IMG_isJXL(SDL_IOStream *src)
@@ -146,7 +147,7 @@ SDL_Surface *IMG_LoadJXL_IO(SDL_IOStream *src)
     }
     start = SDL_TellIO(src);
 
-    if ((IMG_Init(IMG_INIT_JXL) & IMG_INIT_JXL) == 0) {
+    if (!IMG_InitJXL()) {
         return NULL;
     }
 
@@ -254,16 +255,6 @@ SDL_Surface *IMG_LoadJXL_IO(SDL_IOStream *src)
 #pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
 #endif
 
-int IMG_InitJXL(void)
-{
-    SDL_SetError("JXL images are not supported");
-    return -1;
-}
-
-void IMG_QuitJXL(void)
-{
-}
-
 /* See if an image is contained in a data source */
 bool IMG_isJXL(SDL_IOStream *src)
 {
diff --git a/src/IMG_lbm.c b/src/IMG_lbm.c
index 5031fa0e..e1765fd2 100644
--- a/src/IMG_lbm.c
+++ b/src/IMG_lbm.c
@@ -32,7 +32,6 @@
 
 #include <SDL3/SDL_endian.h>
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_LBM
 
diff --git a/src/IMG_pcx.c b/src/IMG_pcx.c
index 8cfe8db0..2be548b9 100644
--- a/src/IMG_pcx.c
+++ b/src/IMG_pcx.c
@@ -36,7 +36,6 @@
 #include <SDL3/SDL_endian.h>
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_PCX
 
diff --git a/src/IMG_png.c b/src/IMG_png.c
index dbebcfa3..6e26ba9f 100644
--- a/src/IMG_png.c
+++ b/src/IMG_png.c
@@ -22,7 +22,6 @@
 /* This is a PNG image file loading framework */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 /* We'll have PNG save support by default */
 #if !defined(SDL_IMAGE_SAVE_PNG)
@@ -132,19 +131,19 @@ static struct {
 #ifdef LOAD_PNG_DYNAMIC
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = (SIG) SDL_LoadFunction(lib.handle, #FUNC); \
-    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return -1; }
+    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return false; }
 #else
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = FUNC;
 #endif
 
-int IMG_InitPNG(void)
+static bool IMG_InitPNG(void)
 {
     if ( lib.loaded == 0 ) {
 #ifdef LOAD_PNG_DYNAMIC
         lib.handle = SDL_LoadObject(LOAD_PNG_DYNAMIC);
         if ( lib.handle == NULL ) {
-            return -1;
+            return false;
         }
 #endif
         FUNCTION_LOADER(png_create_info_struct, png_infop (*) (png_noconst15_structrp png_ptr))
@@ -185,8 +184,9 @@ int IMG_InitPNG(void)
     }
     ++lib.loaded;
 
-    return 0;
+    return true;
 }
+#if 0
 void IMG_QuitPNG(void)
 {
     if ( lib.loaded == 0 ) {
@@ -199,6 +199,7 @@ void IMG_QuitPNG(void)
     }
     --lib.loaded;
 }
+#endif // 0
 
 /* See if an image is contained in a data source */
 bool IMG_isPNG(SDL_IOStream *src)
@@ -470,7 +471,7 @@ SDL_Surface *IMG_LoadPNG_IO(SDL_IOStream *src)
         return NULL;
     }
 
-    if ( (IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) == 0 ) {
+    if (!IMG_InitPNG()) {
         return NULL;
     }
 
@@ -503,17 +504,6 @@ SDL_Surface *IMG_LoadPNG_IO(SDL_IOStream *src)
 
 extern SDL_Surface *IMG_LoadSTB_IO(SDL_IOStream *src);
 
-int IMG_InitPNG(void)
-{
-    /* Nothing to load */
-    return 0;
-}
-
-void IMG_QuitPNG(void)
-{
-    /* Nothing to unload */
-}
-
 /* FIXME: This is a copypaste from LIBPNG! Pull that out of the ifdefs */
 /* See if an image is contained in a data source */
 bool IMG_isPNG(SDL_IOStream *src)
@@ -553,16 +543,6 @@ SDL_Surface *IMG_LoadPNG_IO(SDL_IOStream *src)
 #pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
 #endif
 
-int IMG_InitPNG(void)
-{
-    SDL_SetError("PNG images are not supported");
-    return -1;
-}
-
-void IMG_QuitPNG(void)
-{
-}
-
 /* See if an image is contained in a data source */
 bool IMG_isPNG(SDL_IOStream *src)
 {
@@ -711,7 +691,7 @@ static bool IMG_SavePNG_IO_libpng(SDL_Surface *surface, SDL_IOStream *dst)
     struct savepng_vars vars;
     bool result;
 
-    if (!IMG_Init(IMG_INIT_PNG)) {
+    if (!IMG_InitPNG()) {
         return false;
     }
 
diff --git a/src/IMG_pnm.c b/src/IMG_pnm.c
index 21b0fbf9..6ed6104a 100644
--- a/src/IMG_pnm.c
+++ b/src/IMG_pnm.c
@@ -28,7 +28,6 @@
  */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_PNM
 
diff --git a/src/IMG_qoi.c b/src/IMG_qoi.c
index 3c0ba314..e6a6c95f 100644
--- a/src/IMG_qoi.c
+++ b/src/IMG_qoi.c
@@ -24,7 +24,6 @@
  */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 #include <limits.h> /* for INT_MAX */
 
 #ifdef LOAD_QOI
diff --git a/src/IMG_stb.c b/src/IMG_stb.c
index ff8cab4c..77622fd8 100644
--- a/src/IMG_stb.c
+++ b/src/IMG_stb.c
@@ -20,7 +20,6 @@
 */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef USE_STBIMAGE
 
diff --git a/src/IMG_svg.c b/src/IMG_svg.c
index a042f2cb..7582ddc8 100644
--- a/src/IMG_svg.c
+++ b/src/IMG_svg.c
@@ -24,7 +24,6 @@
  */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_SVG
 
diff --git a/src/IMG_tga.c b/src/IMG_tga.c
index 270c7945..65501724 100644
--- a/src/IMG_tga.c
+++ b/src/IMG_tga.c
@@ -26,7 +26,6 @@
 #include <SDL3/SDL_endian.h>
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_TGA
 
diff --git a/src/IMG_tif.c b/src/IMG_tif.c
index a405c7cc..cfe786f6 100644
--- a/src/IMG_tif.c
+++ b/src/IMG_tif.c
@@ -24,7 +24,6 @@
 /* This is a TIFF image file loading framework */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_TIF
 
@@ -43,19 +42,19 @@ static struct {
 #ifdef LOAD_TIF_DYNAMIC
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = (SIG) SDL_LoadFunction(lib.handle, #FUNC); \
-    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return -1; }
+    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle); return false; }
 #else
 #define FUNCTION_LOADER(FUNC, SIG) \
     lib.FUNC = FUNC;
 #endif
 
-int IMG_InitTIF(void)
+static bool IMG_InitTIF(void)
 {
     if ( lib.loaded == 0 ) {
 #ifdef LOAD_TIF_DYNAMIC
         lib.handle = SDL_LoadObject(LOAD_TIF_DYNAMIC);
         if ( lib.handle == NULL ) {
-            return -1;
+            return false;
         }
 #endif
         FUNCTION_LOADER(TIFFClientOpen, TIFF * (*)(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc))
@@ -66,8 +65,9 @@ int IMG_InitTIF(void)
     }
     ++lib.loaded;
 
-    return 0;
+    return true;
 }
+#if 0
 void IMG_QuitTIF(void)
 {
     if ( lib.loaded == 0 ) {
@@ -80,6 +80,7 @@ void IMG_QuitTIF(void)
     }
     --lib.loaded;
 }
+#endif // 0
 
 /*
  * These are the thunking routine to use the SDL_IOStream* routines from
@@ -180,7 +181,7 @@ SDL_Surface* IMG_LoadTIF_IO(SDL_IOStream * src)
     }
     start = SDL_TellIO(src);
 
-    if ( (IMG_Init(IMG_INIT_TIF) & IMG_INIT_TIF) == 0 ) {
+    if (!IMG_InitTIF()) {
         return NULL;
     }
 
@@ -221,16 +222,6 @@ SDL_Surface* IMG_LoadTIF_IO(SDL_IOStream * src)
 #pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
 #endif
 
-int IMG_InitTIF(void)
-{
-    SDL_SetError("TIFF images are not supported");
-    return -1;
-}
-
-void IMG_QuitTIF(void)
-{
-}
-
 /* See if an image is contained in a data source */
 bool IMG_isTIF(SDL_IOStream *src)
 {
diff --git a/src/IMG_webp.c b/src/IMG_webp.c
index 0b2bbfea..57e76d3a 100644
--- a/src/IMG_webp.c
+++ b/src/IMG_webp.c
@@ -22,7 +22,6 @@
 /* This is a WEBP image file loading framework */
 
 #include <SDL3_image/SDL_image.h>
-#include "IMG.h"
 
 #ifdef LOAD_WEBP
 
@@ -59,34 +58,34 @@ static struct {
 #if defined(LOAD_WEBP_DYNAMIC) && defined(LOAD_WEBPDEMUX_DYNAMIC)
 #define FUNCTION_LOADER_LIBWEBP(FUNC, SIG) \
     lib.FUNC = (SIG) SDL_LoadFunction(lib.handle_libwebp, #FUNC); \
-    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle_libwebp); return -1; }
+    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle_libwebp); return false; }
 #define FUNCTION_LOADER_LIBWEBPDEMUX(FUNC, SIG) \
     lib.FUNC = (SIG) SDL_LoadFunction(lib.handle_libwebpdemux, #FUNC); \
-    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle_libwebpdemux); return -1; }
+    if (lib.FUNC == NULL) { SDL_UnloadObject(lib.handle_libwebpdemux); return false; }
 #else
 #define FUNCTION_LOADER_LIBWEBP(FUNC, SIG) \
     lib.FUNC = FUNC; \
-    if (lib.FUNC == NULL) { SDL_SetError("Missing webp.framework"); return -1; }
+    if (lib.FUNC == NULL) { return SDL_SetError("Missing webp.framework"); }
 #define FUNCTION_LOADER_LIBWEBPDEMUX(FUNC, SIG) \
     lib.FUNC = FUNC; \
-    if (lib.FUNC == NULL) { SDL_SetError("Missing webpdemux.framework"); return -1; }
+    if (lib.FUNC == NULL) { return SDL_SetError("Missing webpdemux.framework"); }
 #endif
 
 #ifdef __APPLE__
     /* Need to turn off optimizations so weak framework load check works */
     __attribute__ ((optnone))
 #endif
-int IMG_InitWEBP(void)
+static bool IMG_InitWEBP(void)
 {
     if (lib.loaded == 0) {
 #if defined(LOAD_WEBP_DYNAMIC) && defined(LOAD_WEBPDEMUX_DYNAMIC)
         lib.handle_libwebpdemux = SDL_LoadObject(LOAD_WEBPDEMUX_DYNAMIC);
         if (lib.handle_libwebpdemux == NULL) {
-            return -1;
+            return false;
         }
         lib.handle_libwebp = SDL_LoadObject(LOAD_WEBP_DYNAMIC);
         if (lib.handle_libwebp == NULL) {
-            return -1;
+            return false;
         }
 #endif
         FUNCTION_LOADER_LIBWEBP(WebPGetFeaturesInternal, VP8StatusCode (*) (const uint8_t *data, size_t data_size, WebPBitstreamFeatures* features, int decoder_abi_version))
@@ -99,8 +98,9 @@ int IMG_InitWEBP(void)
     }
     ++lib.loaded;
 
-    return 0;
+    return true;
 }
+#if 0
 void IMG_QuitWEBP(void)
 {
     if (lib.loaded == 0) {
@@ -114,6 +114,7 @@ void IMG_QuitWEBP(void)
     }
     --lib.loaded;
 }
+#endif // 0
 
 static bool webp_getinfo(SDL_IOStream *src, size_t *datasize)
 {
@@ -179,7 +180,7 @@ SDL_Surface *IMG_LoadWEBP_IO(SDL_IOStream *src)
 
     start = SDL_TellIO(src);
 
-    if ((IMG_Init(IMG_INIT_WEBP) & IMG_INIT_WEBP) == 0) {
+    if (!IMG_InitWEBP()) {
         goto error;
     }
 
@@ -283,7 +284,7 @@ IMG_Animation *IMG_LoadWEBPAnimation_IO(SDL_IOStream *src)
 
     start = SDL_TellIO(src);
 
-    if ((IMG_Init(IMG_INIT_WEBP) & IMG_INIT_WEBP) == 0) {
+    if (!IMG_InitWEBP()) {
         goto error;
     }
 
@@ -385,16 +386,6 @@ IMG_Animation *IMG_LoadWEBPAnimation_IO(SDL_IOStream *src)
 #pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal paramet

(Patch may be truncated, please check the link at the top of this post.)