summaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authornia <nia@pkgsrc.org>2020-05-14 16:42:13 +0000
committernia <nia@pkgsrc.org>2020-05-14 16:42:13 +0000
commitab671242579db03293da9f417b252628b5729c32 (patch)
tree6c28f8f60e2fc233b1472d5c676f7015aa5d55a8 /graphics
parentb5320e37f90f1bc5bc150f63e85814ad2d8eb588 (diff)
downloadpkgsrc-ab671242579db03293da9f417b252628b5729c32.tar.gz
freeimage: Force use of unbundled libraries.
Most Linux distributions have been forcing this for a while, because the reference image libraries are often full of bugs and slow to do releases, so everyone (including us) is carrying lots of local patches for security fixes. Bump PKGREVISION
Diffstat (limited to 'graphics')
-rw-r--r--graphics/freeimage/Makefile50
-rw-r--r--graphics/freeimage/PLIST9
-rw-r--r--graphics/freeimage/distinfo26
-rw-r--r--graphics/freeimage/patches/patch-Makefile.fip49
-rw-r--r--graphics/freeimage/patches/patch-Makefile.gnu (renamed from graphics/freeimage/patches/patch-Makefile)32
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage.h71
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImageToolkit_JPEGTransform.cpp21
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_J2KHelper.cpp15
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PSDParser.cpp71
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_Plugin.cpp29
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginEXR.cpp33
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginJ2K.cpp15
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginJP2.cpp15
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginJPEG.cpp19
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginPNG.cpp17
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginRAW.cpp15
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginTIFF.cpp35
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_PluginWebP.cpp19
-rw-r--r--graphics/freeimage/patches/patch-Source_FreeImage_ZLibInterface.cpp27
-rw-r--r--graphics/freeimage/patches/patch-Source_LibOpenJPEG_opj__malloc.h15
-rw-r--r--graphics/freeimage/patches/patch-Source_LibRawLite_internal_dcraw__common.cpp24
-rw-r--r--graphics/freeimage/patches/patch-Source_Metadata_TagConversion.cpp18
-rw-r--r--graphics/freeimage/patches/patch-Source_Metadata_XTIFF.cpp123
-rw-r--r--graphics/freeimage/patches/patch-Source_Utilities.h21
-rw-r--r--graphics/freeimage/patches/patch-genfipsrclist.sh21
-rw-r--r--graphics/freeimage/patches/patch-gensrclist.sh14
26 files changed, 677 insertions, 127 deletions
diff --git a/graphics/freeimage/Makefile b/graphics/freeimage/Makefile
index 692fe1c99ef..e0e45a1ca28 100644
--- a/graphics/freeimage/Makefile
+++ b/graphics/freeimage/Makefile
@@ -1,8 +1,9 @@
-# $NetBSD: Makefile,v 1.10 2020/01/18 23:32:11 rillig Exp $
+# $NetBSD: Makefile,v 1.11 2020/05/14 16:42:13 nia Exp $
DISTNAME= FreeImage3180
PKGNAME= freeimage-3.18.0
-CATEGORIES= devel graphics
+PKGREVISION= 1
+CATEGORIES= graphics
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=freeimage/}
EXTRACT_SUFX= .zip
@@ -11,33 +12,42 @@ HOMEPAGE= https://freeimage.sf.net/
COMMENT= Library for supporting PNG, BMP, JPEG, and TIFF
LICENSE= gnu-gpl-v2 OR gnu-gpl-v3 OR mpl-1.0
-USE_LANGUAGES+= c c++03
+USE_LANGUAGES+= c c++11
USE_TOOLS+= gmake
WRKSRC= ${WRKDIR}/FreeImage
+MAKE_FILE= Makefile.gnu
+
INSTALLATION_DIRS+= include lib share/doc/${PKGBASE}
-post-install:
- ${INSTALL_DATA} ${WRKSRC}/Source/LibJXR/LICENCE \
- ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}/LICENSE.LibJXR
- ${INSTALL_DATA} ${WRKSRC}/Source/LibOpenJPEG/LICENSE \
- ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}/LICENSE.OpenJPEG
- ${HEAD} -n 31 ${WRKSRC}/Source/LibRawLite/internal/libraw_x3f.cpp \
- > ${WRKDIR}/LICENSE.x3f
- ${HEAD} -n 33 ${WRKSRC}/Source/LibRawLite/internal/dcb_demosaicing.c \
- > ${WRKDIR}/LICENSE.dcb
- ${HEAD} -n 25 ${WRKSRC}/Source/LibTIFF4/tif_open.c \
- > ${WRKDIR}/LICENSE.LibTIFF4
- ${INSTALL_DATA} ${WRKDIR}/LICENSE.* \
- ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}
- ${INSTALL_DATA} ${WRKSRC}/Source/LibWebP/COPYING \
- ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}/LICENSE.LibWebP
- ${INSTALL_DATA} ${WRKSRC}/Source/OpenEXR/Copyrights/openexr/LICENSE \
- ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}/LICENSE.OpenEXR
+pre-configure:
+ # G3 and JPEGTransform can't be built,
+ # due to using private headers in bundled libs
+ cd ${WRKSRC} && ${RM} -r Source/Lib* \
+ Source/ZLib \
+ Source/OpenEXR \
+ Source/FreeImage/PluginG3.cpp \
+ Source/FreeImage/PluginJXR.cpp \
+ Source/FreeImageToolkit/JPEGTransform.cpp
+ cd ${WRKSRC} && ${SH} gensrclist.sh
+ cd ${WRKSRC} && ${SH} genfipsrclist.sh
+ ${SED} \
+ -e 's| \./Source/FreeImage/PluginG3\.cpp||g' \
+ -e 's| \./Source/FreeImage/PluginJXR\.cpp||g' \
+ -e 's| \./Source/FreeImageToolkit/JPEGTransform\.cpp||g' \
+ ${WRKSRC}/Makefile.srcs > ${WRKSRC}/Makefile.srcs.new
+ ${MV} ${WRKSRC}/Makefile.srcs.new ${WRKSRC}/Makefile.srcs
PLIST_SUBST+= PKGVERSION_NOREV=${PKGVERSION_NOREV}
NOT_FOR_PLATFORM= Darwin-*-*
+.include "../../graphics/libraw/buildlink3.mk"
+.include "../../graphics/libwebp/buildlink3.mk"
+.include "../../graphics/openexr/buildlink3.mk"
+.include "../../graphics/openjpeg/buildlink3.mk"
+.include "../../graphics/png/buildlink3.mk"
+.include "../../graphics/tiff/buildlink3.mk"
+.include "../../mk/jpeg.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"
diff --git a/graphics/freeimage/PLIST b/graphics/freeimage/PLIST
index 59fc2d1020a..53c68f7bf37 100644
--- a/graphics/freeimage/PLIST
+++ b/graphics/freeimage/PLIST
@@ -1,13 +1,6 @@
-@comment $NetBSD: PLIST,v 1.2 2017/08/11 15:26:20 nros Exp $
+@comment $NetBSD: PLIST,v 1.3 2020/05/14 16:42:13 nia Exp $
include/FreeImage.h
lib/libfreeimage-${PKGVERSION_NOREV}.so
lib/libfreeimage.a
lib/libfreeimage.so
lib/libfreeimage.so.3
-share/doc/freeimage/LICENSE.LibJXR
-share/doc/freeimage/LICENSE.LibTIFF4
-share/doc/freeimage/LICENSE.LibWebP
-share/doc/freeimage/LICENSE.OpenEXR
-share/doc/freeimage/LICENSE.OpenJPEG
-share/doc/freeimage/LICENSE.dcb
-share/doc/freeimage/LICENSE.x3f
diff --git a/graphics/freeimage/distinfo b/graphics/freeimage/distinfo
index 6ba3d552b6a..5d6b2a9522f 100644
--- a/graphics/freeimage/distinfo
+++ b/graphics/freeimage/distinfo
@@ -1,10 +1,26 @@
-$NetBSD: distinfo,v 1.8 2020/03/21 16:41:41 rillig Exp $
+$NetBSD: distinfo,v 1.9 2020/05/14 16:42:13 nia Exp $
SHA1 (FreeImage3180.zip) = 38daa9d8f1bca2330a2eaa42ec66fbe6ede7dce9
RMD160 (FreeImage3180.zip) = b791715fccf49355a3cb27b6250d8ed809c2454e
SHA512 (FreeImage3180.zip) = 9d9cc7e2d57552c3115e277aeb036e0455204d389026b17a3f513da5be1fd595421655488bb1ec2f76faebed66049119ca55e26e2a6d37024b3fb7ef36ad4818
Size (FreeImage3180.zip) = 7415716 bytes
-SHA1 (patch-Makefile) = d453337cb2a34f4480d1bd3c2115cb93715170b8
-SHA1 (patch-Makefile.fip) = 466b82e70d06f9552a73d86a742aa1bd3450f881
-SHA1 (patch-Source_LibOpenJPEG_opj__malloc.h) = 7e8b65d17cf1f0ed295964d477b96acac56bd927
-SHA1 (patch-Source_LibRawLite_internal_dcraw__common.cpp) = 3f9a149c7294b3ed3f2c17f4c28fe5b7cc223838
+SHA1 (patch-Makefile.gnu) = 1aa31ec7566565e9e59d06bfa2cd729500a0d2cb
+SHA1 (patch-Source_FreeImage.h) = 9b648a8734a0c3391850e2dd7eaa501d29e99689
+SHA1 (patch-Source_FreeImageToolkit_JPEGTransform.cpp) = 4e7372c8947b4359de4d428bcfcfa2f55210f2e8
+SHA1 (patch-Source_FreeImage_J2KHelper.cpp) = a479a373f5a584978129c00d723251a784210603
+SHA1 (patch-Source_FreeImage_PSDParser.cpp) = ee4f3e1bb2b6644033a93ac58e12b9126d0dd060
+SHA1 (patch-Source_FreeImage_Plugin.cpp) = 58f5d7ca78a66ad7109b0e8dff219c26dfe50a86
+SHA1 (patch-Source_FreeImage_PluginEXR.cpp) = 6c4f6ea9a413d27dee940f24588bdf6f7ae38038
+SHA1 (patch-Source_FreeImage_PluginJ2K.cpp) = bbc44884aba8be3af2aa824da5cf788d91c27fb6
+SHA1 (patch-Source_FreeImage_PluginJP2.cpp) = 9a6d27e039b2050004a2d331389bdfa32dffe681
+SHA1 (patch-Source_FreeImage_PluginJPEG.cpp) = a3998454b11c2f73890828b24c0ea276bff7ee7f
+SHA1 (patch-Source_FreeImage_PluginPNG.cpp) = 0d9c71856a9355f56c3e9a571a414098d8af2e88
+SHA1 (patch-Source_FreeImage_PluginRAW.cpp) = 1d67ad2b634e2a5b1fa82be240a4d6edfad7c05d
+SHA1 (patch-Source_FreeImage_PluginTIFF.cpp) = 5fc6f4a9debf555ba41ff7bd4311ed76ec3f1b51
+SHA1 (patch-Source_FreeImage_PluginWebP.cpp) = d7b57cfcb1379c6a849edb219c8a59edae83ff5c
+SHA1 (patch-Source_FreeImage_ZLibInterface.cpp) = 73211e8ecefb7972f1fcb579dc4a17409c81c480
+SHA1 (patch-Source_Metadata_TagConversion.cpp) = 0785cc5dd395bca538e9a82cadbb7ef450eebe86
+SHA1 (patch-Source_Metadata_XTIFF.cpp) = bfcafc31b8407258c52f30fa0c62d062ce108c00
+SHA1 (patch-Source_Utilities.h) = bb9cdd7d72c46e72cd3a636beb27541783609191
+SHA1 (patch-genfipsrclist.sh) = 9b22593e0ca5ff869ea22ddb91f46785ae45d5cd
+SHA1 (patch-gensrclist.sh) = 2582848736654138b3ebdda9d8469046e992745b
diff --git a/graphics/freeimage/patches/patch-Makefile.fip b/graphics/freeimage/patches/patch-Makefile.fip
deleted file mode 100644
index 3b830b85bd0..00000000000
--- a/graphics/freeimage/patches/patch-Makefile.fip
+++ /dev/null
@@ -1,49 +0,0 @@
-$NetBSD: patch-Makefile.fip,v 1.3 2020/01/11 14:40:44 nia Exp $
-
-* use c++ for linking instead of linking with stdc++
-
---- Makefile.fip.orig 2015-03-08 17:03:56.000000000 +0000
-+++ Makefile.fip
-@@ -5,8 +5,8 @@ include fipMakefile.srcs
-
- # General configuration variables:
- DESTDIR ?= /
--INCDIR ?= $(DESTDIR)/usr/include
--INSTALLDIR ?= $(DESTDIR)/usr/lib
-+INCDIR ?= $(DESTDIR)/$(PREFIX)/include
-+INSTALLDIR ?= $(DESTDIR)/$(PREFIX)/lib
-
- # Converts cr/lf to just lf
- DOS2UNIX = dos2unix
-@@ -28,10 +28,8 @@ CXXFLAGS ?= -O3 -fPIC -fexceptions -fvis
- CXXFLAGS += -D__ANSI__
- CXXFLAGS += $(INCLUDE)
-
--ifeq ($(shell sh -c 'uname -m 2>/dev/null || echo not'),x86_64)
-- CFLAGS += -fPIC
-- CXXFLAGS += -fPIC
--endif
-+CFLAGS += -fPIC
-+CXXFLAGS += -fPIC
-
- TARGET = freeimageplus
- STATICLIB = lib$(TARGET).a
-@@ -68,14 +66,12 @@ $(STATICLIB): $(MODULES)
- $(AR) r $@ $(MODULES)
-
- $(SHAREDLIB): $(MODULES)
-- $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
-+ $(CXX) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES)
-
- install:
-- install -d $(INCDIR) $(INSTALLDIR)
-- install -m 644 -o root -g root $(HEADER) $(INCDIR)
-- install -m 644 -o root -g root $(HEADERFIP) $(INCDIR)
-- install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
-- install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
-+ $(BSD_INSTALL_DATA) $(HEADERFIP) $(INCDIR)
-+ $(BSD_INSTALL_DATA) $(STATICLIB) $(INSTALLDIR)
-+ $(BSD_INSTALL_LIB) $(SHAREDLIB) $(INSTALLDIR)
- ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
- ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)
-
diff --git a/graphics/freeimage/patches/patch-Makefile b/graphics/freeimage/patches/patch-Makefile.gnu
index c0469f8b8b8..e2f8fe52c45 100644
--- a/graphics/freeimage/patches/patch-Makefile
+++ b/graphics/freeimage/patches/patch-Makefile.gnu
@@ -1,10 +1,12 @@
-$NetBSD: patch-Makefile,v 1.3 2020/01/11 14:40:44 nia Exp $
+$NetBSD: patch-Makefile.gnu,v 1.1 2020/05/14 16:42:14 nia Exp $
-* use c++ for linking instead of linking with stdc++
+- Use pkgsrc directories.
+- Link with CXX for libstdc++.
+- Unbundle image libraries.
---- Makefile.gnu.orig 2015-03-08 17:04:00.000000000 +0000
+--- Makefile.gnu.orig 2015-03-10 09:04:00.000000000 +0000
+++ Makefile.gnu
-@@ -5,8 +5,8 @@ include Makefile.srcs
+@@ -5,14 +5,17 @@ include Makefile.srcs
# General configuration variables:
DESTDIR ?= /
@@ -15,7 +17,16 @@ $NetBSD: patch-Makefile,v 1.3 2020/01/11 14:40:44 nia Exp $
# Converts cr/lf to just lf
DOS2UNIX = dos2unix
-@@ -28,10 +28,8 @@ CXXFLAGS ?= -O3 -fPIC -fexceptions -fvis
+
+ LIBRARIES = -lstdc++
+
++INCLUDE += $(shell pkg-config --cflags libjpeg OpenEXR libopenjp2 libraw libpng libtiff-4 libwebp libwebpmux zlib)
++LDFLAGS += $(shell pkg-config --libs libjpeg OpenEXR libopenjp2 libraw libpng libtiff-4 libwebp libwebpmux zlib)
++
+ MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
+ CFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden
+@@ -28,10 +31,8 @@ CXXFLAGS ?= -O3 -fPIC -fexceptions -fvis
CXXFLAGS += -D__ANSI__
CXXFLAGS += $(INCLUDE)
@@ -28,7 +39,16 @@ $NetBSD: patch-Makefile,v 1.3 2020/01/11 14:40:44 nia Exp $
TARGET = freeimage
STATICLIB = lib$(TARGET).a
-@@ -67,13 +65,12 @@ $(STATICLIB): $(MODULES)
+@@ -40,8 +41,6 @@ LIBNAME = lib$(TARGET).so
+ VERLIBNAME = $(LIBNAME).$(VER_MAJOR)
+ HEADER = Source/FreeImage.h
+
+-
+-
+ default: all
+
+ all: dist
+@@ -67,13 +66,12 @@ $(STATICLIB): $(MODULES)
$(AR) r $@ $(MODULES)
$(SHAREDLIB): $(MODULES)
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage.h b/graphics/freeimage/patches/patch-Source_FreeImage.h
new file mode 100644
index 00000000000..cf9e2c89cdf
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage.h
@@ -0,0 +1,71 @@
+$NetBSD: patch-Source_FreeImage.h,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage.h.orig 2018-03-25 17:42:20.000000000 +0000
++++ Source/FreeImage.h
+@@ -155,8 +155,11 @@ typedef uint8_t BYTE;
+ typedef uint16_t WORD;
+ typedef uint32_t DWORD;
+ typedef int32_t LONG;
++// Disable these, they conflict with the (wrong) ones of libraw
++#if 0
+ typedef int64_t INT64;
+ typedef uint64_t UINT64;
++#endif
+ #else
+ // MS is not C99 ISO compliant
+ typedef long BOOL;
+@@ -410,7 +413,12 @@ FI_ENUM(FREE_IMAGE_FORMAT) {
+ FIF_DDS = 24,
+ FIF_GIF = 25,
+ FIF_HDR = 26,
+- FIF_FAXG3 = 27,
++/* The G3 fax format plugin is deliberately disabled in the Fedora build of
++ FreeImage as it requires that FreeImage uses a private copy of libtiff
++ which is a no no because of security reasons. */
++#if 0
++ FIF_FAXG3 = 27,
++#endif
+ FIF_SGI = 28,
+ FIF_EXR = 29,
+ FIF_J2K = 30,
+@@ -473,6 +481,10 @@ FI_ENUM(FREE_IMAGE_DITHER) {
+ FID_BAYER16x16 = 6 //! Bayer ordered dispersed dot dithering (order 4 dithering matrix)
+ };
+
++/* The FreeImage_JPEGTransform functions are deliberately disabled in the
++ Fedora build of FreeImage as they require that FreeImage uses a private copy
++ of libjpeg which is a no no because of security reasons. */
++#if 0
+ /** Lossless JPEG transformations
+ Constants used in FreeImage_JPEGTransform
+ */
+@@ -486,6 +498,7 @@ FI_ENUM(FREE_IMAGE_JPEG_OPERATION) {
+ FIJPEG_OP_ROTATE_180 = 6, //! 180-degree rotation
+ FIJPEG_OP_ROTATE_270 = 7 //! 270-degree clockwise (or 90 ccw)
+ };
++#endif
+
+ /** Tone mapping operators.
+ Constants used in FreeImage_ToneMapping.
+@@ -1088,7 +1101,10 @@ DLL_API const char* DLL_CALLCONV FreeIma
+ // --------------------------------------------------------------------------
+ // JPEG lossless transformation routines
+ // --------------------------------------------------------------------------
+-
++/* The FreeImage_JPEGTransform functions are deliberately disabled in the
+++ Fedora build of FreeImage as they require that FreeImage uses a private copy
+++ of libjpeg which is a no no because of security reasons. */
++#if 0
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom);
+@@ -1097,6 +1113,7 @@ DLL_API BOOL DLL_CALLCONV FreeImage_JPEG
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
++#endif
+
+
+ // --------------------------------------------------------------------------
diff --git a/graphics/freeimage/patches/patch-Source_FreeImageToolkit_JPEGTransform.cpp b/graphics/freeimage/patches/patch-Source_FreeImageToolkit_JPEGTransform.cpp
new file mode 100644
index 00000000000..19351f8cd82
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImageToolkit_JPEGTransform.cpp
@@ -0,0 +1,21 @@
+$NetBSD: patch-Source_FreeImageToolkit_JPEGTransform.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImageToolkit/JPEGTransform.cpp.orig 2015-03-04 00:07:10.000000000 +0000
++++ Source/FreeImageToolkit/JPEGTransform.cpp
+@@ -26,10 +26,10 @@ extern "C" {
+ #undef FAR
+ #include <setjmp.h>
+
+-#include "../LibJPEG/jinclude.h"
+-#include "../LibJPEG/jpeglib.h"
+-#include "../LibJPEG/jerror.h"
+-#include "../LibJPEG/transupp.h"
++#include <jinclude.h>
++#include <jpeglib.h>
++#include <jerror.h>
++#include <transupp.h>
+ }
+
+ #include "FreeImage.h"
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_J2KHelper.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_J2KHelper.cpp
new file mode 100644
index 00000000000..909e8214414
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_J2KHelper.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-Source_FreeImage_J2KHelper.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/J2KHelper.cpp.orig 2015-03-04 00:07:08.000000000 +0000
++++ Source/FreeImage/J2KHelper.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // --------------------------------------------------------------------------
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PSDParser.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PSDParser.cpp
new file mode 100644
index 00000000000..4722cf4e322
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PSDParser.cpp
@@ -0,0 +1,71 @@
+$NetBSD: patch-Source_FreeImage_PSDParser.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PSDParser.cpp.orig 2016-02-11 04:18:02.000000000 +0000
++++ Source/FreeImage/PSDParser.cpp
+@@ -133,8 +133,8 @@ public:
+ template <>
+ class PSDGetValue<8> {
+ public:
+- static inline UINT64 get(const BYTE * iprBuffer) {
+- UINT64 v = ((const UINT64*)iprBuffer)[0];
++ static inline uint64_t get(const BYTE * iprBuffer) {
++ uint64_t v = ((const uint64_t*)iprBuffer)[0];
+ #ifndef FREEIMAGE_BIGENDIAN
+ SwapInt64(&v);
+ #endif
+@@ -147,7 +147,7 @@ public:
+
+ // --------------------------------------------------------------------------
+
+-static UINT64
++static uint64_t
+ psdReadSize(FreeImageIO *io, fi_handle handle, const psdHeaderInfo& header) {
+ if(header._Version == 1) {
+ BYTE Length[4];
+@@ -199,11 +199,11 @@ public:
+ template <>
+ class PSDSetValue<8> {
+ public:
+- static inline void set(const BYTE * iprBuffer, UINT64 v) {
++ static inline void set(const BYTE * iprBuffer, uint64_t v) {
+ #ifndef FREEIMAGE_BIGENDIAN
+ SwapInt64(&v);
+ #endif
+- ((UINT64*)iprBuffer)[0] = v;
++ ((uint64_t*)iprBuffer)[0] = v;
+ }
+ };
+
+@@ -213,7 +213,7 @@ public:
+ // --------------------------------------------------------------------------
+
+ static inline bool
+-psdWriteSize(FreeImageIO *io, fi_handle handle, const psdHeaderInfo& header, UINT64 v) {
++psdWriteSize(FreeImageIO *io, fi_handle handle, const psdHeaderInfo& header, uint64_t v) {
+ if(header._Version == 1) {
+ BYTE Length[4];
+ psdSetLongValue(Length, sizeof(Length), (DWORD)v);
+@@ -1063,10 +1063,10 @@ unsigned psdParser::GetChannelOffset(FIB
+ bool psdParser::ReadLayerAndMaskInfoSection(FreeImageIO *io, fi_handle handle) {
+ bool bSuccess = true;
+
+- UINT64 nTotalBytes = psdReadSize(io, handle, _headerInfo);
++ uint64_t nTotalBytes = psdReadSize(io, handle, _headerInfo);
+
+ // Hack to handle large PSB files without using fseeko().
+- if (sizeof(long) < sizeof(UINT64)) {
++ if (sizeof(long) < sizeof(uint64_t)) {
+ const long offset = 0x10000000;
+ while (nTotalBytes > offset) {
+ if (io->seek_proc(handle, offset, SEEK_CUR) != 0) {
+@@ -1672,7 +1672,7 @@ bool psdParser::WriteLayerAndMaskInfoSec
+ // Short section with no layers.
+ BYTE IntValue[4];
+
+- UINT64 size;
++ uint64_t size;
+ if(_headerInfo._Version == 1) {
+ size = 8;
+ } else {
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_Plugin.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_Plugin.cpp
new file mode 100644
index 00000000000..3344f863997
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_Plugin.cpp
@@ -0,0 +1,29 @@
+$NetBSD: patch-Source_FreeImage_Plugin.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/Plugin.cpp.orig 2017-02-18 15:09:28.000000000 +0000
++++ Source/FreeImage/Plugin.cpp
+@@ -263,7 +263,12 @@ FreeImage_Initialise(BOOL load_local_plu
+ s_plugins->AddNode(InitDDS);
+ s_plugins->AddNode(InitGIF);
+ s_plugins->AddNode(InitHDR);
+- s_plugins->AddNode(InitG3);
++/* The G3 fax format plugin is deliberately disabled in the build of
++ FreeImage as it requires that FreeImage uses a private copy of libtiff
++ which is a no no because of security reasons. */
++#if 0
++ s_plugins->AddNode(InitG3);
++#endif
+ s_plugins->AddNode(InitSGI);
+ s_plugins->AddNode(InitEXR);
+ s_plugins->AddNode(InitJ2K);
+@@ -272,7 +277,7 @@ FreeImage_Initialise(BOOL load_local_plu
+ s_plugins->AddNode(InitPICT);
+ s_plugins->AddNode(InitRAW);
+ s_plugins->AddNode(InitWEBP);
+-#if !(defined(_MSC_VER) && (_MSC_VER <= 1310))
++#if 0
+ s_plugins->AddNode(InitJXR);
+ #endif // unsupported by MS Visual Studio 2003 !!!
+
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginEXR.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginEXR.cpp
new file mode 100644
index 00000000000..ff3d087cd86
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginEXR.cpp
@@ -0,0 +1,33 @@
+$NetBSD: patch-Source_FreeImage_PluginEXR.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginEXR.cpp.orig 2015-03-04 00:07:08.000000000 +0000
++++ Source/FreeImage/PluginEXR.cpp
+@@ -28,16 +28,16 @@
+ #pragma warning (disable : 4800) // ImfVersion.h - 'const int' : forcing value to bool 'true' or 'false' (performance warning)
+ #endif
+
+-#include "../OpenEXR/IlmImf/ImfIO.h"
+-#include "../OpenEXR/Iex/Iex.h"
+-#include "../OpenEXR/IlmImf/ImfOutputFile.h"
+-#include "../OpenEXR/IlmImf/ImfInputFile.h"
+-#include "../OpenEXR/IlmImf/ImfRgbaFile.h"
+-#include "../OpenEXR/IlmImf/ImfChannelList.h"
+-#include "../OpenEXR/IlmImf/ImfRgba.h"
+-#include "../OpenEXR/IlmImf/ImfArray.h"
+-#include "../OpenEXR/IlmImf/ImfPreviewImage.h"
+-#include "../OpenEXR/Half/half.h"
++#include <OpenEXR/ImfIO.h>
++#include <OpenEXR/Iex.h>
++#include <OpenEXR/ImfOutputFile.h>
++#include <OpenEXR/ImfInputFile.h>
++#include <OpenEXR/ImfRgbaFile.h>
++#include <OpenEXR/ImfChannelList.h>
++#include <OpenEXR/ImfRgba.h>
++#include <OpenEXR/ImfArray.h>
++#include <OpenEXR/ImfPreviewImage.h>
++#include <OpenEXR/half.h>
+
+
+ // ==========================================================
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginJ2K.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginJ2K.cpp
new file mode 100644
index 00000000000..290c8338d39
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginJ2K.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-Source_FreeImage_PluginJ2K.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginJ2K.cpp.orig 2015-03-04 00:07:08.000000000 +0000
++++ Source/FreeImage/PluginJ2K.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // ==========================================================
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginJP2.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginJP2.cpp
new file mode 100644
index 00000000000..cca614f12ce
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginJP2.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-Source_FreeImage_PluginJP2.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginJP2.cpp.orig 2015-03-04 00:07:08.000000000 +0000
++++ Source/FreeImage/PluginJP2.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // ==========================================================
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginJPEG.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginJPEG.cpp
new file mode 100644
index 00000000000..5fe2fc12f19
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginJPEG.cpp
@@ -0,0 +1,19 @@
+$NetBSD: patch-Source_FreeImage_PluginJPEG.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginJPEG.cpp.orig 2018-07-28 18:22:24.000000000 +0000
++++ Source/FreeImage/PluginJPEG.cpp
+@@ -35,9 +35,9 @@ extern "C" {
+ #undef FAR
+ #include <setjmp.h>
+
+-#include "../LibJPEG/jinclude.h"
+-#include "../LibJPEG/jpeglib.h"
+-#include "../LibJPEG/jerror.h"
++#include <stdio.h>
++#include <jpeglib.h>
++#include <jerror.h>
+ }
+
+ #include "FreeImage.h"
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginPNG.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginPNG.cpp
new file mode 100644
index 00000000000..6a90cbd5bb5
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginPNG.cpp
@@ -0,0 +1,17 @@
+$NetBSD: patch-Source_FreeImage_PluginPNG.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginPNG.cpp.orig 2018-07-28 19:15:26.000000000 +0000
++++ Source/FreeImage/PluginPNG.cpp
+@@ -40,8 +40,8 @@
+
+ // ----------------------------------------------------------
+
+-#include "../ZLib/zlib.h"
+-#include "../LibPNG/png.h"
++#include <zlib.h>
++#include <png.h>
+
+ // ----------------------------------------------------------
+
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginRAW.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginRAW.cpp
new file mode 100644
index 00000000000..ac2f34b441f
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginRAW.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-Source_FreeImage_PluginRAW.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginRAW.cpp.orig 2015-03-10 11:12:04.000000000 +0000
++++ Source/FreeImage/PluginRAW.cpp
+@@ -19,7 +19,7 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../LibRawLite/libraw/libraw.h"
++#include <libraw/libraw.h>
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginTIFF.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginTIFF.cpp
new file mode 100644
index 00000000000..4db321c43e9
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginTIFF.cpp
@@ -0,0 +1,35 @@
+$NetBSD: patch-Source_FreeImage_PluginTIFF.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginTIFF.cpp.orig 2018-07-28 23:24:44.000000000 +0000
++++ Source/FreeImage/PluginTIFF.cpp
+@@ -37,9 +37,9 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibTIFF4/tiffiop.h"
++#include <tiffio.h>
+ #include "../Metadata/FreeImageTag.h"
+-#include "../OpenEXR/Half/half.h"
++#include <OpenEXR/half.h>
+
+ #include "FreeImageIO.h"
+ #include "PSDParser.h"
+@@ -194,16 +194,6 @@ TIFFFdOpen(thandle_t handle, const char
+ return tif;
+ }
+
+-/**
+-Open a TIFF file for reading or writing
+-@param name
+-@param mode
+-*/
+-TIFF*
+-TIFFOpen(const char* name, const char* mode) {
+- return 0;
+-}
+-
+ // ----------------------------------------------------------
+ // TIFF library FreeImage-specific routines.
+ // ----------------------------------------------------------
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_PluginWebP.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_PluginWebP.cpp
new file mode 100644
index 00000000000..67a37a24fc6
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_PluginWebP.cpp
@@ -0,0 +1,19 @@
+$NetBSD: patch-Source_FreeImage_PluginWebP.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/PluginWebP.cpp.orig 2016-06-15 14:48:12.000000000 +0000
++++ Source/FreeImage/PluginWebP.cpp
+@@ -24,9 +24,9 @@
+
+ #include "../Metadata/FreeImageTag.h"
+
+-#include "../LibWebP/src/webp/decode.h"
+-#include "../LibWebP/src/webp/encode.h"
+-#include "../LibWebP/src/webp/mux.h"
++#include <webp/decode.h>
++#include <webp/encode.h>
++#include <webp/mux.h>
+
+ // ==========================================================
+ // Plugin Interface
diff --git a/graphics/freeimage/patches/patch-Source_FreeImage_ZLibInterface.cpp b/graphics/freeimage/patches/patch-Source_FreeImage_ZLibInterface.cpp
new file mode 100644
index 00000000000..1c7c3931a6f
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_FreeImage_ZLibInterface.cpp
@@ -0,0 +1,27 @@
+$NetBSD: patch-Source_FreeImage_ZLibInterface.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/FreeImage/ZLibInterface.cpp.orig 2015-03-04 00:07:10.000000000 +0000
++++ Source/FreeImage/ZLibInterface.cpp
+@@ -19,10 +19,9 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../ZLib/zlib.h"
++#include <zlib.h>
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
+
+ /**
+ Compresses a source buffer into a target buffer, using the ZLib library.
+@@ -115,7 +114,7 @@ FreeImage_ZLibGZip(BYTE *target, DWORD t
+ return 0;
+ case Z_OK: {
+ // patch header, setup crc and length (stolen from mod_trace_output)
+- BYTE *p = target + 8; *p++ = 2; *p = OS_CODE; // xflags, os_code
++ BYTE *p = target + 8; *p++ = 2; *p = 0x03; // xflags, os_code (unix)
+ crc = crc32(crc, source, source_size);
+ memcpy(target + 4 + dest_len, &crc, 4);
+ memcpy(target + 8 + dest_len, &source_size, 4);
diff --git a/graphics/freeimage/patches/patch-Source_LibOpenJPEG_opj__malloc.h b/graphics/freeimage/patches/patch-Source_LibOpenJPEG_opj__malloc.h
deleted file mode 100644
index 499c488eeed..00000000000
--- a/graphics/freeimage/patches/patch-Source_LibOpenJPEG_opj__malloc.h
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD: patch-Source_LibOpenJPEG_opj__malloc.h,v 1.2 2017/12/26 11:55:01 he Exp $
-
-Add a case for NetBSD.
-
---- Source/LibOpenJPEG/opj_malloc.h.orig 2015-02-12 12:40:33.000000000 -0800
-+++ Source/LibOpenJPEG/opj_malloc.h 2015-02-12 12:42:08.000000000 -0800
-@@ -95,6 +95,8 @@ Allocate memory aligned to a 16 byte bou
- #define HAVE_MEMALIGN
- #elif defined(__FreeBSD__)
- #define HAVE_POSIX_MEMALIGN
-+ #elif defined(__NetBSD__)
-+ #define HAVE_POSIX_MEMALIGN
- /* Linux x86_64 and OSX always align allocations to 16 bytes */
- #elif !defined(__amd64__) && !defined(__APPLE__) && !defined(_AIX)
- #define HAVE_MEMALIGN
diff --git a/graphics/freeimage/patches/patch-Source_LibRawLite_internal_dcraw__common.cpp b/graphics/freeimage/patches/patch-Source_LibRawLite_internal_dcraw__common.cpp
deleted file mode 100644
index 2a21729267a..00000000000
--- a/graphics/freeimage/patches/patch-Source_LibRawLite_internal_dcraw__common.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-$NetBSD: patch-Source_LibRawLite_internal_dcraw__common.cpp,v 1.1 2020/03/21 16:41:41 rillig Exp $
-
-Source/LibRawLite/internal/dcraw_common.cpp: In member function 'void LibRaw::xtrans_interpolate(int)':
-Source/LibRawLite/internal/dcraw_common.cpp:5879:27: error: array subscript has type 'char' [-Werror=char-subscripts]
- cstat[fcol(row, col)]++;
- ^
-
-The expected values for fcol must be in the range 0..3 anyway, otherwise
-the behavior is undefined. Instead of using char, it would probably be
-better to use uint8_t here.
-
-https://sourceforge.net/p/freeimage/bugs/322/
-
---- Source/LibRawLite/internal/dcraw_common.cpp.orig 2018-06-30 02:08:06.000000000 +0000
-+++ Source/LibRawLite/internal/dcraw_common.cpp
-@@ -5876,7 +5876,7 @@ void CLASS xtrans_interpolate(int passes
- /* Check against right pattern */
- for (row = 0; row < 6; row++)
- for (col = 0; col < 6; col++)
-- cstat[fcol(row, col)]++;
-+ cstat[(unsigned char)fcol(row, col)]++;
-
- if (cstat[0] < 6 || cstat[0] > 10 || cstat[1] < 16 || cstat[1] > 24 || cstat[2] < 6 || cstat[2] > 10 || cstat[3])
- throw LIBRAW_EXCEPTION_IO_CORRUPT;
diff --git a/graphics/freeimage/patches/patch-Source_Metadata_TagConversion.cpp b/graphics/freeimage/patches/patch-Source_Metadata_TagConversion.cpp
new file mode 100644
index 00000000000..d799fd74ec7
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_Metadata_TagConversion.cpp
@@ -0,0 +1,18 @@
+$NetBSD: patch-Source_Metadata_TagConversion.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/Metadata/TagConversion.cpp.orig 2018-03-25 11:30:54.000000000 +0000
++++ Source/Metadata/TagConversion.cpp
+@@ -30,6 +30,11 @@
+
+ #define MAX_TEXT_EXTENT 512
+
++// These were in FreeImage.h, but are moved here to avoid conflicts (see note in FreeImage.h)
++typedef int64_t INT64;
++typedef uint64_t UINT64;
++
++
+ /**
+ Convert a tag to a C string
+ */
diff --git a/graphics/freeimage/patches/patch-Source_Metadata_XTIFF.cpp b/graphics/freeimage/patches/patch-Source_Metadata_XTIFF.cpp
new file mode 100644
index 00000000000..ca2903720ba
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_Metadata_XTIFF.cpp
@@ -0,0 +1,123 @@
+$NetBSD: patch-Source_Metadata_XTIFF.cpp,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/Metadata/XTIFF.cpp.orig 2015-03-04 00:07:10.000000000 +0000
++++ Source/Metadata/XTIFF.cpp
+@@ -29,13 +29,18 @@
+ #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
+ #endif
+
+-#include "../LibTIFF4/tiffiop.h"
++#include <tiffio.h>
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+ #include "FreeImageTag.h"
+ #include "FIRational.h"
+
++extern "C"
++{
++ int _TIFFDataSize(TIFFDataType type);
++}
++
+ // ----------------------------------------------------------
+ // Extended TIFF Directory GEO Tag Support
+ // ----------------------------------------------------------
+@@ -224,6 +229,33 @@ tiff_write_geotiff_profile(TIFF *tif, FI
+ // TIFF EXIF tag reading & writing
+ // ----------------------------------------------------------
+
++static uint32 exif_tag_ids[] = {
++ EXIFTAG_EXPOSURETIME, EXIFTAG_FNUMBER, EXIFTAG_EXPOSUREPROGRAM,
++ EXIFTAG_SPECTRALSENSITIVITY, EXIFTAG_ISOSPEEDRATINGS, EXIFTAG_OECF,
++ EXIFTAG_EXIFVERSION, EXIFTAG_DATETIMEORIGINAL, EXIFTAG_DATETIMEDIGITIZED,
++ EXIFTAG_COMPONENTSCONFIGURATION, EXIFTAG_COMPRESSEDBITSPERPIXEL,
++ EXIFTAG_SHUTTERSPEEDVALUE, EXIFTAG_APERTUREVALUE,
++ EXIFTAG_BRIGHTNESSVALUE, EXIFTAG_EXPOSUREBIASVALUE,
++ EXIFTAG_MAXAPERTUREVALUE, EXIFTAG_SUBJECTDISTANCE, EXIFTAG_METERINGMODE,
++ EXIFTAG_LIGHTSOURCE, EXIFTAG_FLASH, EXIFTAG_FOCALLENGTH,
++ EXIFTAG_SUBJECTAREA, EXIFTAG_MAKERNOTE, EXIFTAG_USERCOMMENT,
++ EXIFTAG_SUBSECTIME, EXIFTAG_SUBSECTIMEORIGINAL,
++ EXIFTAG_SUBSECTIMEDIGITIZED, EXIFTAG_FLASHPIXVERSION, EXIFTAG_COLORSPACE,
++ EXIFTAG_PIXELXDIMENSION, EXIFTAG_PIXELYDIMENSION,
++ EXIFTAG_RELATEDSOUNDFILE, EXIFTAG_FLASHENERGY,
++ EXIFTAG_SPATIALFREQUENCYRESPONSE, EXIFTAG_FOCALPLANEXRESOLUTION,
++ EXIFTAG_FOCALPLANEYRESOLUTION, EXIFTAG_FOCALPLANERESOLUTIONUNIT,
++ EXIFTAG_SUBJECTLOCATION, EXIFTAG_EXPOSUREINDEX, EXIFTAG_SENSINGMETHOD,
++ EXIFTAG_FILESOURCE, EXIFTAG_SCENETYPE, EXIFTAG_CFAPATTERN,
++ EXIFTAG_CUSTOMRENDERED, EXIFTAG_EXPOSUREMODE, EXIFTAG_WHITEBALANCE,
++ EXIFTAG_DIGITALZOOMRATIO, EXIFTAG_FOCALLENGTHIN35MMFILM,
++ EXIFTAG_SCENECAPTURETYPE, EXIFTAG_GAINCONTROL, EXIFTAG_CONTRAST,
++ EXIFTAG_SATURATION, EXIFTAG_SHARPNESS, EXIFTAG_DEVICESETTINGDESCRIPTION,
++ EXIFTAG_SUBJECTDISTANCERANGE, EXIFTAG_GAINCONTROL, EXIFTAG_GAINCONTROL,
++ EXIFTAG_IMAGEUNIQUEID
++};
++static int nExifTags = sizeof(exif_tag_ids) / sizeof(exif_tag_ids[0]);
++
+ /**
+ Read a single Exif tag
+
+@@ -575,45 +607,11 @@ tiff_read_exif_tags(TIFF *tif, TagLib::M
+
+ // loop over all Core Directory Tags
+ // ### uses private data, but there is no other way
++ // -> Fedora: Best we can do without private headers is to hard-code a list of known EXIF tags and read those
+ if(md_model == TagLib::EXIF_MAIN) {
+- const TIFFDirectory *td = &tif->tif_dir;
+-
+- uint32 lastTag = 0; //<- used to prevent reading some tags twice (as stored in tif_fieldinfo)
+-
+- for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
+- const TIFFField *fld = tif->tif_fields[fi];
+-
+- const uint32 tag_id = TIFFFieldTag(fld);
+-
+- if(tag_id == lastTag) {
+- continue;
+- }
+-
+- // test if tag value is set
+- // (lifted directly from LibTiff _TIFFWriteDirectory)
+-
+- if( fld->field_bit == FIELD_CUSTOM ) {
+- int is_set = FALSE;
+-
+- for(int ci = 0; ci < td->td_customValueCount; ci++ ) {
+- is_set |= (td->td_customValues[ci].info == fld);
+- }
+-
+- if( !is_set ) {
+- continue;
+- }
+-
+- } else if(!TIFFFieldSet(tif, fld->field_bit)) {
+- continue;
+- }
+-
+- // process *all* other tags (some will be ignored)
+-
+- tiff_read_exif_tag(tif, tag_id, dib, md_model);
+-
+- lastTag = tag_id;
++ for (int i = 0; i < nExifTags; ++i) {
++ tiff_read_exif_tag(tif, exif_tag_ids[i], dib, md_model);
+ }
+-
+ }
+
+ return TRUE;
+@@ -723,10 +721,9 @@ tiff_write_exif_tags(TIFF *tif, TagLib::
+
+ TagLib& tag_lib = TagLib::instance();
+
+- for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
+- const TIFFField *fld = tif->tif_fields[fi];
+-
+- const uint32 tag_id = TIFFFieldTag(fld);
++ for (int fi = 0; fi < nExifTags; fi++) {
++ const uint32 tag_id = exif_tag_ids[fi];
++ const TIFFField *fld = TIFFFieldWithTag(tif, tag_id);
+
+ if(skip_write_field(tif, tag_id)) {
+ // skip tags that are already handled by the LibTIFF writing process
diff --git a/graphics/freeimage/patches/patch-Source_Utilities.h b/graphics/freeimage/patches/patch-Source_Utilities.h
new file mode 100644
index 00000000000..3f840d01e3c
--- /dev/null
+++ b/graphics/freeimage/patches/patch-Source_Utilities.h
@@ -0,0 +1,21 @@
+$NetBSD: patch-Source_Utilities.h,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- Source/Utilities.h.orig 2016-04-11 14:15:32.000000000 +0000
++++ Source/Utilities.h
+@@ -446,12 +446,12 @@ SwapLong(DWORD *lp) {
+ }
+
+ inline void
+-SwapInt64(UINT64 *arg) {
++SwapInt64(uint64_t *arg) {
+ #if defined(_MSC_VER) && _MSC_VER >= 1310
+ *arg = _byteswap_uint64(*arg);
+ #else
+ union Swap {
+- UINT64 sv;
++ uint64_t sv;
+ DWORD ul[2];
+ } tmp, result;
+ tmp.sv = *arg;
diff --git a/graphics/freeimage/patches/patch-genfipsrclist.sh b/graphics/freeimage/patches/patch-genfipsrclist.sh
new file mode 100644
index 00000000000..e1ac9fadcbe
--- /dev/null
+++ b/graphics/freeimage/patches/patch-genfipsrclist.sh
@@ -0,0 +1,21 @@
+$NetBSD: patch-genfipsrclist.sh,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- genfipsrclist.sh.orig 2018-07-28 17:53:18.000000000 +0000
++++ genfipsrclist.sh
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+
+-DIRLIST=". Source Source/Metadata Source/FreeImageToolkit Source/LibJPEG Source/LibPNG Source/LibTIFF4 Source/ZLib Source/LibOpenJPEG Source/OpenEXR Source/OpenEXR/Half Source/OpenEXR/Iex Source/OpenEXR/IlmImf Source/OpenEXR/IlmThread Source/OpenEXR/Imath Source/OpenEXR/IexMath Source/LibRawLite Source/LibRawLite/dcraw Source/LibRawLite/internal Source/LibRawLite/libraw Source/LibRawLite/src Source/LibWebP Source/LibJXR Source/LibJXR/common/include Source/LibJXR/image/sys Source/LibJXR/jxrgluelib Wrapper/FreeImagePlus"
++DIRLIST="Wrapper/FreeImagePlus"
+
+
+ echo "VER_MAJOR = 3" > fipMakefile.srcs
+@@ -19,5 +19,6 @@ echo -n "INCLUDE =" >> fipMakefile.srcs
+ for DIR in $DIRLIST; do
+ echo -n " -I$DIR" >> fipMakefile.srcs
+ done
++echo -n " -IDist" >> fipMakefile.srcs
+ echo >> fipMakefile.srcs
+
diff --git a/graphics/freeimage/patches/patch-gensrclist.sh b/graphics/freeimage/patches/patch-gensrclist.sh
new file mode 100644
index 00000000000..ab45802e148
--- /dev/null
+++ b/graphics/freeimage/patches/patch-gensrclist.sh
@@ -0,0 +1,14 @@
+$NetBSD: patch-gensrclist.sh,v 1.1 2020/05/14 16:42:14 nia Exp $
+
+Unbundle image libraries.
+
+--- gensrclist.sh.orig 2018-07-28 17:52:50.000000000 +0000
++++ gensrclist.sh
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+
+-DIRLIST=". Source Source/Metadata Source/FreeImageToolkit Source/LibJPEG Source/LibPNG Source/LibTIFF4 Source/ZLib Source/LibOpenJPEG Source/OpenEXR Source/OpenEXR/Half Source/OpenEXR/Iex Source/OpenEXR/IlmImf Source/OpenEXR/IlmThread Source/OpenEXR/Imath Source/OpenEXR/IexMath Source/LibRawLite Source/LibRawLite/dcraw Source/LibRawLite/internal Source/LibRawLite/libraw Source/LibRawLite/src Source/LibWebP Source/LibJXR Source/LibJXR/common/include Source/LibJXR/image/sys Source/LibJXR/jxrgluelib"
++DIRLIST=". Source Source/Metadata Source/FreeImageToolkit"
+
+ echo "VER_MAJOR = 3" > Makefile.srcs
+ echo "VER_MINOR = 18.0" >> Makefile.srcs