aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/freeimage
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/freeimage
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/freeimage')
-rw-r--r--vcpkg/ports/freeimage/CMakeLists.txt164
-rw-r--r--vcpkg/ports/freeimage/FreeImageConfig-dynamic.h6
-rw-r--r--vcpkg/ports/freeimage/FreeImageConfig-static.h6
-rw-r--r--vcpkg/ports/freeimage/disable-plugins-depending-on-internal-third-party-libraries.patch89
-rw-r--r--vcpkg/ports/freeimage/fix-function-overload.patch40
-rw-r--r--vcpkg/ports/freeimage/portfile.cmake57
-rw-r--r--vcpkg/ports/freeimage/rawlib-build-fix.patch31
-rw-r--r--vcpkg/ports/freeimage/remove_auto_ptr.patch35
-rw-r--r--vcpkg/ports/freeimage/typedef-xcode.patch14
-rw-r--r--vcpkg/ports/freeimage/use-external-jpeg.patch17
-rw-r--r--vcpkg/ports/freeimage/use-external-jxrlib.patch14
-rw-r--r--vcpkg/ports/freeimage/use-external-libtiff.patch204
-rw-r--r--vcpkg/ports/freeimage/use-external-openexr.patch72
-rw-r--r--vcpkg/ports/freeimage/use-external-openjpeg.patch39
-rw-r--r--vcpkg/ports/freeimage/use-external-png-zlib.patch40
-rw-r--r--vcpkg/ports/freeimage/use-external-rawlib.patch13
-rw-r--r--vcpkg/ports/freeimage/use-external-webp.patch17
-rw-r--r--vcpkg/ports/freeimage/use-freeimage-config-include.patch16
-rw-r--r--vcpkg/ports/freeimage/use-functions-to-override-libtiff-warning-error-handlers.patch31
-rw-r--r--vcpkg/ports/freeimage/use-typedef-as-already-declared.patch15
-rw-r--r--vcpkg/ports/freeimage/vcpkg.json35
21 files changed, 955 insertions, 0 deletions
diff --git a/vcpkg/ports/freeimage/CMakeLists.txt b/vcpkg/ports/freeimage/CMakeLists.txt
new file mode 100644
index 0000000..60f9783
--- /dev/null
+++ b/vcpkg/ports/freeimage/CMakeLists.txt
@@ -0,0 +1,164 @@
+cmake_minimum_required(VERSION 3.4)
+
+include(GNUInstallDirs)
+
+project(FreeImage C CXX)
+
+if(MSVC)
+ add_definitions("-D_CRT_SECURE_NO_WARNINGS")
+ set(CMAKE_CXX_FLAGS "/wd4828 ${CMAKE_CXX_FLAGS}")
+endif()
+
+find_package(ZLIB REQUIRED)
+find_package(PNG REQUIRED)
+find_package(JPEG REQUIRED)
+find_package(TIFF REQUIRED)
+find_package(OpenJPEG REQUIRED)
+find_package(WebP CONFIG REQUIRED)
+find_package(JXR REQUIRED)
+find_package(LibRaw REQUIRED)
+find_package(OpenEXR REQUIRED)
+
+option(BUILD_SHARED_LIBS "Build shared libraries" ON)
+option(INSTALL_HEADERS "Install the development headers" ON)
+
+set(REAL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Source)
+
+# Add a debug postfix
+set(CMAKE_DEBUG_POSTFIX "d")
+
+# List the public header files
+set(PUBLIC_HEADERS ${REAL_SOURCE_DIR}/FreeImage.h)
+
+# List the private header files
+set(ROOT_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/CacheFile.h
+ ${REAL_SOURCE_DIR}/FreeImageIO.h
+ ${REAL_SOURCE_DIR}/MapIntrospector.h
+ ${REAL_SOURCE_DIR}/Plugin.h
+ ${REAL_SOURCE_DIR}/Quantizers.h
+ ${REAL_SOURCE_DIR}/ToneMapping.h
+ ${REAL_SOURCE_DIR}/Utilities.h)
+
+file(GLOB FREEIMAGE_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/FreeImage/*.h)
+file(GLOB FREEIMAGE_TOOLKIT_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/FreeImageToolkit/*.h)
+file(GLOB METADATA_PRIVATE_HEADERS ${REAL_SOURCE_DIR}/Metadata/*.h)
+
+set(PRIVATE_HEADERS ${ROOT_PRIVATE_HEADERS}
+ ${FREEIMAGE_PRIVATE_HEADERS}
+ ${FREEIMAGE_TOOLKIT_PRIVATE_HEADERS}
+ ${METADATA_PRIVATE_HEADERS})
+
+# List the source files
+file(GLOB DEPRECATION_SRCS ${REAL_SOURCE_DIR}/DeprecationManager/*.cpp)
+file(GLOB FREEIMAGE_TOOLKIT_SRCS ${REAL_SOURCE_DIR}/FreeImageToolkit/*.cpp)
+file(GLOB FREEIMAGE_SRCS ${REAL_SOURCE_DIR}/FreeImage/*.cpp)
+file(GLOB METADATA_SRCS ${REAL_SOURCE_DIR}/Metadata/*.cpp)
+
+# The G3 plugin is disabled because it require the private copy of tiff
+list(REMOVE_ITEM FREEIMAGE_SRCS ${REAL_SOURCE_DIR}/FreeImage/PluginG3.cpp)
+
+# The JPEGTransform plugin is disable because it requires a private copy of jpeg
+list(REMOVE_ITEM FREEIMAGE_TOOLKIT_SRCS ${REAL_SOURCE_DIR}/FreeImageToolkit/JPEGTransform.cpp)
+
+
+set(SRCS ${DEPRECATION_SRCS}
+ ${FREEIMAGE_SRCS}
+ ${FREEIMAGE_TOOLKIT_SRCS}
+ ${METADATA_SRCS}
+)
+
+# If FreeImage is used as a static library, FREEIMAGE_LIB
+# needs to be defined (at the C preprocessor level) to correctly
+# define (to nothing instead of _declspec(dllimport) ) the DLL_API macro.
+# For this purpouse we include (depending on the BUILD_SHARED_LIBS )
+# the appropriate FreeImageConfig.h .
+if(BUILD_SHARED_LIBS)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FreeImageConfig-dynamic.h ${CMAKE_CURRENT_BINARY_DIR}/FreeImageConfig.h)
+else()
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FreeImageConfig-static.h ${CMAKE_CURRENT_BINARY_DIR}/FreeImageConfig.h)
+endif()
+list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/FreeImageConfig.h)
+
+add_library(FreeImage ${SRCS} ${PRIVATE_HEADERS} ${PUBLIC_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/FreeImage.rc)
+
+if(BUILD_SHARED_LIBS)
+ target_compile_definitions(FreeImage PRIVATE -DFREEIMAGE_EXPORTS)
+else()
+ target_compile_definitions(FreeImage PRIVATE -DFREEIMAGE_LIB)
+endif()
+
+target_include_directories(FreeImage PRIVATE ${REAL_SOURCE_DIR}
+ ${ZLIB_INCLUDE_DIRS}
+ ${JPEG_INCLUDE_DIRS}
+ ${TIFF_INCLUDE_DIRS}
+ ${PNG_INCLUDE_DIRS}
+ ${OPENJPEG_INCLUDE_DIRS}
+ ${JXR_INCLUDE_DIRS}
+ ${LibRaw_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+
+
+target_link_libraries(FreeImage ${ZLIB_LIBRARIES}
+ ${JPEG_LIBRARIES}
+ ${TIFF_LIBRARIES}
+ ${PNG_LIBRARIES}
+ ${OPENJPEG_LIBRARIES}
+ WebP::webp WebP::webpdemux WebP::libwebpmux WebP::webpdecoder
+ ${JXR_LIBRARIES}
+ ${LibRaw_LIBRARIES}
+ OpenEXR::OpenEXR
+ Imath::Imath)
+
+target_compile_definitions(FreeImage PRIVATE ${PNG_DEFINITIONS})
+
+# FreeImagePlus
+file(GLOB FREEIMAGEPLUS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/src/*.cpp)
+add_library(FreeImagePlus
+ ${FREEIMAGEPLUS_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/FreeImagePlus.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/FreeImagePlus.rc)
+
+if(BUILD_SHARED_LIBS)
+ target_compile_definitions(FreeImagePlus PRIVATE -DFIP_EXPORTS)
+else()
+ target_compile_definitions(FreeImagePlus PRIVATE -DFREEIMAGE_LIB)
+endif()
+
+target_include_directories(FreeImagePlus PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${REAL_SOURCE_DIR}
+ PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+
+target_link_libraries(FreeImagePlus PUBLIC FreeImage)
+
+list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Wrapper/FreeImagePlus/FreeImagePlus.h)
+
+install(TARGETS FreeImage FreeImagePlus
+ EXPORT freeimage-targets
+ COMPONENT runtime
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+
+install(EXPORT freeimage-targets NAMESPACE freeimage:: DESTINATION share/freeimage)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freeimage-config.cmake"
+"include(CMakeFindDependencyMacro)
+find_dependency(ZLIB)
+find_dependency(PNG)
+find_dependency(JPEG)
+find_dependency(TIFF)
+find_dependency(OpenJPEG)
+find_dependency(WebP CONFIG)
+find_dependency(JXR)
+find_dependency(LibRaw)
+find_dependency(OpenEXR)
+find_dependency(Imath)
+include(\"\${CMAKE_CURRENT_LIST_DIR}/freeimage-targets.cmake\")
+")
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freeimage-config.cmake DESTINATION share/freeimage)
+if(INSTALL_HEADERS)
+ install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+endif()
diff --git a/vcpkg/ports/freeimage/FreeImageConfig-dynamic.h b/vcpkg/ports/freeimage/FreeImageConfig-dynamic.h
new file mode 100644
index 0000000..41dcf57
--- /dev/null
+++ b/vcpkg/ports/freeimage/FreeImageConfig-dynamic.h
@@ -0,0 +1,6 @@
+#ifndef FREEIMAGE_CONFIG_H
+#define FREEIMAGE_CONFIG_H
+
+#undef FREEIMAGE_LIB
+
+#endif
diff --git a/vcpkg/ports/freeimage/FreeImageConfig-static.h b/vcpkg/ports/freeimage/FreeImageConfig-static.h
new file mode 100644
index 0000000..ed72349
--- /dev/null
+++ b/vcpkg/ports/freeimage/FreeImageConfig-static.h
@@ -0,0 +1,6 @@
+#ifndef FREEIMAGE_CONFIG_H
+#define FREEIMAGE_CONFIG_H
+
+#define FREEIMAGE_LIB
+
+#endif
diff --git a/vcpkg/ports/freeimage/disable-plugins-depending-on-internal-third-party-libraries.patch b/vcpkg/ports/freeimage/disable-plugins-depending-on-internal-third-party-libraries.patch
new file mode 100644
index 0000000..c22828d
--- /dev/null
+++ b/vcpkg/ports/freeimage/disable-plugins-depending-on-internal-third-party-libraries.patch
@@ -0,0 +1,89 @@
+diff --git a/Source/FreeImage.h b/Source/FreeImage.h
+index 12182cd..ebd0453 100644
+--- a/Source/FreeImage.h
++++ b/Source/FreeImage.h
+@@ -410,16 +410,20 @@ FI_ENUM(FREE_IMAGE_FORMAT) {
+ FIF_DDS = 24,
+ FIF_GIF = 25,
+ FIF_HDR = 26,
+- FIF_FAXG3 = 27,
+- FIF_SGI = 28,
+- FIF_EXR = 29,
+- FIF_J2K = 30,
+- FIF_JP2 = 31,
+- FIF_PFM = 32,
+- FIF_PICT = 33,
+- FIF_RAW = 34,
+- FIF_WEBP = 35,
+- FIF_JXR = 36
++/* vcpkg: The G3 fax format plugin is deliberately disabled in our build of
++ FreeImage, since it requires usage of the vendored copy of libtiff. */
++#if 0
++ FIF_FAXG3 = 27,
++#endif
++ FIF_SGI = 27,
++ FIF_EXR = 28,
++ FIF_J2K = 29,
++ FIF_JP2 = 30,
++ FIF_PFM = 31,
++ FIF_PICT = 32,
++ FIF_RAW = 33,
++ FIF_WEBP = 34,
++ FIF_JXR = 35
+ };
+
+ /** Image type used in FreeImage.
+@@ -476,6 +480,9 @@ FI_ENUM(FREE_IMAGE_DITHER) {
+ /** Lossless JPEG transformations
+ Constants used in FreeImage_JPEGTransform
+ */
++/* vcpkg: The JPEGTransform functions are deliberately disabled in our build
++ of FreeImage, since they require usage of the vendored copy of libjpeg. */
++#if 0
+ FI_ENUM(FREE_IMAGE_JPEG_OPERATION) {
+ FIJPEG_OP_NONE = 0, //! no transformation
+ FIJPEG_OP_FLIP_H = 1, //! horizontal flip
+@@ -486,6 +493,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.
+@@ -1089,6 +1097,9 @@ DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model,
+ // JPEG lossless transformation routines
+ // --------------------------------------------------------------------------
+
++/* vcpkg: The JPEGTransform functions are deliberately disabled in our build
++ of FreeImage, since they require usage of the vendored copy of libjpeg. */
++#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,7 +1108,7 @@ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformFromHandle(FreeImageIO* src_io,
+ 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
+
+ // --------------------------------------------------------------------------
+ // Image manipulation toolkit
+diff --git a/Source/FreeImage/Plugin.cpp b/Source/FreeImage/Plugin.cpp
+index 11e7294..0119ba7 100644
+--- a/Source/FreeImage/Plugin.cpp
++++ b/Source/FreeImage/Plugin.cpp
+@@ -263,7 +263,11 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
+ s_plugins->AddNode(InitDDS);
+ s_plugins->AddNode(InitGIF);
+ s_plugins->AddNode(InitHDR);
+- s_plugins->AddNode(InitG3);
++/* vcpkg: The G3 fax format plugin is deliberately disabled in our build of FreeImage
+++ since it requires usage of the vendored copy of libtiff. */
++#if 0
++ s_plugins->AddNode(InitG3);
++#endif
+ s_plugins->AddNode(InitSGI);
+ s_plugins->AddNode(InitEXR);
+ s_plugins->AddNode(InitJ2K);
diff --git a/vcpkg/ports/freeimage/fix-function-overload.patch b/vcpkg/ports/freeimage/fix-function-overload.patch
new file mode 100644
index 0000000..adb1164
--- /dev/null
+++ b/vcpkg/ports/freeimage/fix-function-overload.patch
@@ -0,0 +1,40 @@
+diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp
+index 8db177d..efa2c4e 100644
+--- a/Source/FreeImage/PluginJPEG.cpp
++++ b/Source/FreeImage/PluginJPEG.cpp
+@@ -503,7 +503,7 @@ marker_is_icc(jpeg_saved_marker_ptr marker) {
+ return FALSE. You might want to issue an error message instead.
+ */
+ static BOOL
+-jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
++jpeg_read_icc_profile_(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
+ jpeg_saved_marker_ptr marker;
+ int num_markers = 0;
+ int seq_no;
+@@ -745,7 +745,7 @@ read_markers(j_decompress_ptr cinfo, FIBITMAP *dib) {
+ BYTE *icc_profile = NULL;
+ unsigned icc_length = 0;
+
+- if( jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) {
++ if( jpeg_read_icc_profile_(cinfo, &icc_profile, &icc_length) ) {
+ // copy ICC profile data
+ FreeImage_CreateICCProfile(dib, icc_profile, icc_length);
+ // clean up
+@@ -785,7 +785,7 @@ jpeg_write_comment(j_compress_ptr cinfo, FIBITMAP *dib) {
+ Write JPEG_APP2 marker (ICC profile)
+ */
+ static BOOL
+-jpeg_write_icc_profile(j_compress_ptr cinfo, FIBITMAP *dib) {
++jpeg_write_icc_profile_(j_compress_ptr cinfo, FIBITMAP *dib) {
+ // marker identifying string "ICC_PROFILE" (null-terminated)
+ BYTE icc_signature[12] = { 0x49, 0x43, 0x43, 0x5F, 0x50, 0x52, 0x4F, 0x46, 0x49, 0x4C, 0x45, 0x00 };
+
+@@ -1038,7 +1038,7 @@ write_markers(j_compress_ptr cinfo, FIBITMAP *dib) {
+ jpeg_write_comment(cinfo, dib);
+
+ // write ICC profile
+- jpeg_write_icc_profile(cinfo, dib);
++ jpeg_write_icc_profile_(cinfo, dib);
+
+ // write IPTC profile
+ jpeg_write_iptc_profile(cinfo, dib);
diff --git a/vcpkg/ports/freeimage/portfile.cmake b/vcpkg/ports/freeimage/portfile.cmake
new file mode 100644
index 0000000..2c0554e
--- /dev/null
+++ b/vcpkg/ports/freeimage/portfile.cmake
@@ -0,0 +1,57 @@
+vcpkg_from_sourceforge(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO freeimage/Source%20Distribution
+ REF 3.18.0
+ FILENAME "FreeImage3180.zip"
+ SHA512 9d9cc7e2d57552c3115e277aeb036e0455204d389026b17a3f513da5be1fd595421655488bb1ec2f76faebed66049119ca55e26e2a6d37024b3fb7ef36ad4818
+ PATCHES
+ disable-plugins-depending-on-internal-third-party-libraries.patch
+ use-external-jpeg.patch
+ use-external-jxrlib.patch
+ use-external-libtiff.patch
+ use-external-openjpeg.patch
+ use-external-png-zlib.patch
+ use-external-rawlib.patch
+ use-external-webp.patch
+ use-external-openexr.patch
+ use-freeimage-config-include.patch
+ fix-function-overload.patch
+ use-typedef-as-already-declared.patch
+ use-functions-to-override-libtiff-warning-error-handlers.patch
+ remove_auto_ptr.patch
+ rawlib-build-fix.patch
+ typedef-xcode.patch
+)
+
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt"
+ "${CMAKE_CURRENT_LIST_DIR}/FreeImageConfig-static.h"
+ "${CMAKE_CURRENT_LIST_DIR}/FreeImageConfig-dynamic.h"
+ DESTINATION "${SOURCE_PATH}"
+)
+
+# This is not strictly necessary, but to make sure
+# that no "internal" libraries are used we remove them
+file(REMOVE_RECURSE
+ "${SOURCE_PATH}/Source/LibJPEG"
+ "${SOURCE_PATH}/Source/LibPNG"
+ "${SOURCE_PATH}/Source/LibTIFF4"
+ "${SOURCE_PATH}/Source/ZLib"
+ "${SOURCE_PATH}/Source/LibOpenJPEG"
+ "${SOURCE_PATH}/Source/LibJXR"
+ "${SOURCE_PATH}/Source/LibWebP"
+ "${SOURCE_PATH}/Source/LibRawLite"
+ "${SOURCE_PATH}/Source/OpenEXR"
+)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS_DEBUG
+ -DINSTALL_HEADERS=OFF
+)
+
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup()
+
+vcpkg_copy_pdbs()
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/license-fi.txt")
diff --git a/vcpkg/ports/freeimage/rawlib-build-fix.patch b/vcpkg/ports/freeimage/rawlib-build-fix.patch
new file mode 100644
index 0000000..b5b53dc
--- /dev/null
+++ b/vcpkg/ports/freeimage/rawlib-build-fix.patch
@@ -0,0 +1,31 @@
+diff --git a/Source/FreeImage/PluginRAW.cpp b/Source/FreeImage/PluginRAW.cpp
+index c7f8758a..a57fd5f1 100644
+--- a/Source/FreeImage/PluginRAW.cpp
++++ b/Source/FreeImage/PluginRAW.cpp
+@@ -46,6 +46,14 @@ private:
+ long _eof;
+ INT64 _fsize;
+
++ // Minimal change to make version 3.18.0 of FreeImage compile with
++ // LibRaw 0.20 and later versions.
++ // Once the port of FreeImage has been updated to a version greater
++ // than 3.18.0, this patch should be removed as it will not be needed.
++#if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 20)
++ LibRaw_abstract_datastream * const substream = nullptr;
++#endif
++
+ public:
+ LibRaw_freeimage_datastream(FreeImageIO *io, fi_handle handle) : _io(io), _handle(handle) {
+ long start_pos = io->tell_proc(handle);
+@@ -694,7 +702,11 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
+ // --------------------------------------------
+
+ // (-s [0..N-1]) Select one raw image from input file
++#if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0, 20)
++ RawProcessor->imgdata.rawparams.shot_select = 0;
++#else
+ RawProcessor->imgdata.params.shot_select = 0;
++#endif
+ // (-w) Use camera white balance, if possible (otherwise, fallback to auto_wb)
+ RawProcessor->imgdata.params.use_camera_wb = 1;
+ // (-M) Use any color matrix from the camera metadata. This option only affects Olympus, Leaf, and Phase One cameras.
diff --git a/vcpkg/ports/freeimage/remove_auto_ptr.patch b/vcpkg/ports/freeimage/remove_auto_ptr.patch
new file mode 100644
index 0000000..65315e2
--- /dev/null
+++ b/vcpkg/ports/freeimage/remove_auto_ptr.patch
@@ -0,0 +1,35 @@
+diff --git a/Source/FreeImage/MultiPage.cpp b/Source/FreeImage/MultiPage.cpp
+index 4f2605188..8af384aff 100644
+--- a/Source/FreeImage/MultiPage.cpp
++++ b/Source/FreeImage/MultiPage.cpp
+@@ -31,6 +31,8 @@
+ #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
+ #endif
+
++#include <memory>
++
+ #include "CacheFile.h"
+ #include "FreeImageIO.h"
+ #include "Plugin.h"
+@@ -271,8 +273,8 @@ FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL crea
+ }
+ }
+
+- std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
+- std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
++ std::unique_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
++ std::unique_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
+ header->m_filename = filename;
+ // io is default
+ header->node = node;
+@@ -337,8 +339,8 @@ FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_h
+ PluginNode *node = list->FindNodeFromFIF(fif);
+
+ if (node) {
+- std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
+- std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
++ std::unique_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
++ std::unique_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
+ header->io = *io;
+ header->node = node;
+ header->fif = fif;
diff --git a/vcpkg/ports/freeimage/typedef-xcode.patch b/vcpkg/ports/freeimage/typedef-xcode.patch
new file mode 100644
index 0000000..f50c983
--- /dev/null
+++ b/vcpkg/ports/freeimage/typedef-xcode.patch
@@ -0,0 +1,14 @@
+diff --git a/Source/FreeImage.h b/Source/FreeImage.h
+index ad2574d..9588944 100644
+--- a/Source/FreeImage.h
++++ b/Source/FreeImage.h
+@@ -155,7 +155,9 @@ FI_STRUCT (FIMULTIBITMAP) { void *data; };
+ #ifndef _MSC_VER
+ // define portable types for 32-bit / 64-bit OS
+ #include <inttypes.h>
++#ifndef OBJC_BOOL_DEFINED
+ typedef int32_t BOOL;
++#endif
+ typedef uint8_t BYTE;
+ typedef uint16_t WORD;
+ typedef uint32_t DWORD;
diff --git a/vcpkg/ports/freeimage/use-external-jpeg.patch b/vcpkg/ports/freeimage/use-external-jpeg.patch
new file mode 100644
index 0000000..2df2c9d
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-jpeg.patch
@@ -0,0 +1,17 @@
+diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp
+index 573989c..aaeefa4 100644
+--- a/Source/FreeImage/PluginJPEG.cpp
++++ b/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/vcpkg/ports/freeimage/use-external-jxrlib.patch b/vcpkg/ports/freeimage/use-external-jxrlib.patch
new file mode 100644
index 0000000..d86a18e
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-jxrlib.patch
@@ -0,0 +1,14 @@
+diff --git a/Source/FreeImage/PluginJXR.cpp b/Source/FreeImage/PluginJXR.cpp
+index 0e14e09..8eb9d5d 100644
+--- a/Source/FreeImage/PluginJXR.cpp
++++ b/Source/FreeImage/PluginJXR.cpp
+@@ -23,7 +23,8 @@
+ #include "Utilities.h"
+ #include "../Metadata/FreeImageTag.h"
+
+-#include "../LibJXR/jxrgluelib/JXRGlue.h"
++#define INITGUID
++#include <JXRGlue.h>
+
+ // ==========================================================
+ // Plugin Interface
diff --git a/vcpkg/ports/freeimage/use-external-libtiff.patch b/vcpkg/ports/freeimage/use-external-libtiff.patch
new file mode 100644
index 0000000..23d5dfd
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-libtiff.patch
@@ -0,0 +1,204 @@
+diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp
+index 5068d94..8947b03 100644
+--- a/Source/FreeImage/PluginTIFF.cpp
++++ b/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 "FreeImageIO.h"
+ #include "PSDParser.h"
+@@ -199,15 +199,18 @@ 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.
+ // ----------------------------------------------------------
+
++/*
+ void*
+ _TIFFmalloc(tmsize_t s) {
+ return malloc(s);
+@@ -245,6 +248,7 @@ int
+ _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) {
+ return (memcmp(p1, p2, (size_t) c));
+ }
++*/
+
+ // ----------------------------------------------------------
+ // in FreeImage warnings and errors are disabled
+
+diff --git a/Source/Metadata/XTIFF.cpp b/Source/Metadata/XTIFF.cpp
+index d5be902..8dbcd5d 100644
+--- a/Source/Metadata/XTIFF.cpp
++++ b/Source/Metadata/XTIFF.cpp
+@@ -29,7 +29,7 @@
+ #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
+ #endif
+
+-#include "../LibTIFF4/tiffiop.h"
++#include <tiffio.h>
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+@@ -40,6 +40,43 @@
+ // Extended TIFF Directory GEO Tag Support
+ // ----------------------------------------------------------
+
++// vcpkg: function imported from libtiff/tif_dirinfo.c, in which it is not exported
++/*
++ * Return size of TIFFDataType in bytes.
++ *
++ * XXX: We need a separate function to determine the space needed
++ * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8,
++ * but we use 4-byte float to represent rationals.
++ */
++int
++FreeImage_TIFFDataSize(TIFFDataType type)
++{
++ switch (type)
++ {
++ case TIFF_BYTE:
++ case TIFF_SBYTE:
++ case TIFF_ASCII:
++ case TIFF_UNDEFINED:
++ return 1;
++ case TIFF_SHORT:
++ case TIFF_SSHORT:
++ return 2;
++ case TIFF_LONG:
++ case TIFF_SLONG:
++ case TIFF_FLOAT:
++ case TIFF_IFD:
++ case TIFF_RATIONAL:
++ case TIFF_SRATIONAL:
++ return 4;
++ case TIFF_DOUBLE:
++ case TIFF_LONG8:
++ case TIFF_SLONG8:
++ case TIFF_IFD8:
++ return 8;
++ default:
++ return 0;
++ }
++}
+ /**
+ Tiff info structure.
+ Entry format:
+@@ -224,6 +261,33 @@ tiff_write_geotiff_profile(TIFF *tif, FIBITMAP *dib) {
+ // 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,43 +639,10 @@ tiff_read_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) {
+
+ // loop over all Core Directory Tags
+ // ### uses private data, but there is no other way
++ // -> vcpkg: 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);
+ }
+
+ }
+@@ -723,10 +754,9 @@ tiff_write_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) {
+
+ 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, nfi = nExifTags; nfi > 0; nfi--, 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
+@@ -749,7 +779,7 @@ tiff_write_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) {
+ continue;
+ }
+ // type of storage may differ (e.g. rationnal array vs float array type)
+- if((unsigned)_TIFFDataSize(tif_tag_type) != FreeImage_TagDataWidth(tag_type)) {
++ if((unsigned)FreeImage_TIFFDataSize(tif_tag_type) != FreeImage_TagDataWidth(tag_type)) {
+ // skip tag or _TIFFmemcpy will fail
+ continue;
+ }
diff --git a/vcpkg/ports/freeimage/use-external-openexr.patch b/vcpkg/ports/freeimage/use-external-openexr.patch
new file mode 100644
index 0000000..4f02f71
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-openexr.patch
@@ -0,0 +1,72 @@
+diff --git a/Source/FreeImage/PluginEXR.cpp b/Source/FreeImage/PluginEXR.cpp
+index b286430..82b3b72 100644
+--- a/Source/FreeImage/PluginEXR.cpp
++++ b/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 <Imath/half.h>
+
+
+ // ==========================================================
+@@ -66,11 +66,11 @@ public:
+ return ((unsigned)n != _io->read_proc(c, 1, n, _handle));
+ }
+
+- virtual Imath::Int64 tellg() {
++ virtual uint64_t tellg() {
+ return _io->tell_proc(_handle);
+ }
+
+- virtual void seekg(Imath::Int64 pos) {
++ virtual void seekg(uint64_t pos) {
+ _io->seek_proc(_handle, (unsigned)pos, SEEK_SET);
+ }
+
+@@ -100,11 +100,11 @@ public:
+ }
+ }
+
+- virtual Imath::Int64 tellp() {
++ virtual uint64_t tellp() {
+ return _io->tell_proc(_handle);
+ }
+
+- virtual void seekp(Imath::Int64 pos) {
++ virtual void seekp(uint64_t pos) {
+ _io->seek_proc(_handle, (unsigned)pos, SEEK_SET);
+ }
+ };
+diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp
+index 562fdd7..ce12649 100644
+--- a/Source/FreeImage/PluginTIFF.cpp
++++ b/Source/FreeImage/PluginTIFF.cpp
+@@ -39,7 +39,7 @@
+ #include "Utilities.h"
+ #include <tiffio.h>
+ #include "../Metadata/FreeImageTag.h"
+-#include "../OpenEXR/Half/half.h"
++#include <Imath/half.h>
+
+ #include "FreeImageIO.h"
+ #include "PSDParser.h"
diff --git a/vcpkg/ports/freeimage/use-external-openjpeg.patch b/vcpkg/ports/freeimage/use-external-openjpeg.patch
new file mode 100644
index 0000000..fa4f8e7
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-openjpeg.patch
@@ -0,0 +1,39 @@
+diff --git a/Source/FreeImage/J2KHelper.cpp b/Source/FreeImage/J2KHelper.cpp
+index 1776c3b..538f1c5 100644
+--- a/Source/FreeImage/J2KHelper.cpp
++++ b/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/Source/FreeImage/PluginJ2K.cpp b/Source/FreeImage/PluginJ2K.cpp
+index b8bcfc8..621a903 100644
+--- a/Source/FreeImage/PluginJ2K.cpp
++++ b/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/Source/FreeImage/PluginJP2.cpp b/Source/FreeImage/PluginJP2.cpp
+index 742fe2c..c57f626 100644
+--- a/Source/FreeImage/PluginJP2.cpp
++++ b/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/vcpkg/ports/freeimage/use-external-png-zlib.patch b/vcpkg/ports/freeimage/use-external-png-zlib.patch
new file mode 100644
index 0000000..da489b6
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-png-zlib.patch
@@ -0,0 +1,40 @@
+diff --git a/Source/FreeImage/PluginPNG.cpp b/Source/FreeImage/PluginPNG.cpp
+index ba2ef17..c3c5cd6 100644
+--- a/Source/FreeImage/PluginPNG.cpp
++++ b/Source/FreeImage/PluginPNG.cpp
+@@ -40,8 +40,8 @@
+
+ // ----------------------------------------------------------
+
+-#include "../ZLib/zlib.h"
+-#include "../LibPNG/png.h"
++#include <zlib.h>
++#include <libpng16/png.h>
+
+ // ----------------------------------------------------------
+
+diff --git a/Source/FreeImage/ZLibInterface.cpp b/Source/FreeImage/ZLibInterface.cpp
+index 3ab6d32..725618b 100644
+--- a/Source/FreeImage/ZLibInterface.cpp
++++ b/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 target_size, BYTE *source, DWORD source_s
+ 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
+ crc = crc32(crc, source, source_size);
+ memcpy(target + 4 + dest_len, &crc, 4);
+ memcpy(target + 8 + dest_len, &source_size, 4);
diff --git a/vcpkg/ports/freeimage/use-external-rawlib.patch b/vcpkg/ports/freeimage/use-external-rawlib.patch
new file mode 100644
index 0000000..6afa0bf
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-rawlib.patch
@@ -0,0 +1,13 @@
+diff --git a/Source/FreeImage/PluginRAW.cpp b/Source/FreeImage/PluginRAW.cpp
+index e9bd5bf..c7f8758 100644
+--- a/Source/FreeImage/PluginRAW.cpp
++++ b/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/vcpkg/ports/freeimage/use-external-webp.patch b/vcpkg/ports/freeimage/use-external-webp.patch
new file mode 100644
index 0000000..4d1757c
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-external-webp.patch
@@ -0,0 +1,17 @@
+diff --git a/Source/FreeImage/PluginWebP.cpp b/Source/FreeImage/PluginWebP.cpp
+index 7c9f62f..c401447 100644
+--- a/Source/FreeImage/PluginWebP.cpp
++++ b/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/vcpkg/ports/freeimage/use-freeimage-config-include.patch b/vcpkg/ports/freeimage/use-freeimage-config-include.patch
new file mode 100644
index 0000000..579f088
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-freeimage-config-include.patch
@@ -0,0 +1,16 @@
+diff --git a/Source/FreeImage.h b/Source/FreeImage.h
+index 12182cd..86a1e68 100644
+--- a/Source/FreeImage.h
++++ b/Source/FreeImage.h
+@@ -32,6 +32,11 @@
+ #define FREEIMAGE_MINOR_VERSION 18
+ #define FREEIMAGE_RELEASE_SERIAL 0
+
++// vcpkg specific includes --------------------------------------------------
++// Include FreeImageConfig.h to define FREEIMAGE_LIB in static builds,
++// or do not define it in dynamic builds
++#include "FreeImageConfig.h"
++
+ // Compiler options ---------------------------------------------------------
+
+ #include <wchar.h> // needed for UNICODE functions
diff --git a/vcpkg/ports/freeimage/use-functions-to-override-libtiff-warning-error-handlers.patch b/vcpkg/ports/freeimage/use-functions-to-override-libtiff-warning-error-handlers.patch
new file mode 100644
index 0000000..270331e
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-functions-to-override-libtiff-warning-error-handlers.patch
@@ -0,0 +1,31 @@
+diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp
+index a9fcf0e..b1f7b32 100644
+--- a/Source/FreeImage/PluginTIFF.cpp
++++ b/Source/FreeImage/PluginTIFF.cpp
+@@ -258,7 +258,7 @@ static void
+ msdosWarningHandler(const char* module, const char* fmt, va_list ap) {
+ }
+
+-TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler;
++//TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler;
+
+ static void
+ msdosErrorHandler(const char* module, const char* fmt, va_list ap) {
+@@ -273,7 +273,7 @@ msdosErrorHandler(const char* module, const char* fmt, va_list ap) {
+ */
+ }
+
+-TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler;
++//TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler;
+
+ // ----------------------------------------------------------
+
+@@ -2659,6 +2659,8 @@ InitTIFF(Plugin *plugin, int format_id) {
+ // Set up the callback for extended TIFF directory tag support (see XTIFF.cpp)
+ // Must be called before using libtiff
+ XTIFFInitialize();
++ TIFFSetWarningHandler(msdosWarningHandler);
++ TIFFSetErrorHandler(msdosErrorHandler);
+
+ plugin->format_proc = Format;
+ plugin->description_proc = Description;
diff --git a/vcpkg/ports/freeimage/use-typedef-as-already-declared.patch b/vcpkg/ports/freeimage/use-typedef-as-already-declared.patch
new file mode 100644
index 0000000..80d367b
--- /dev/null
+++ b/vcpkg/ports/freeimage/use-typedef-as-already-declared.patch
@@ -0,0 +1,15 @@
+diff --git a/Source/FreeImage.h b/Source/FreeImage.h
+index 1fd9c2f..59de277 100644
+--- a/Source/FreeImage.h
++++ b/Source/FreeImage.h
+@@ -160,8 +160,8 @@ typedef uint8_t BYTE;
+ typedef uint16_t WORD;
+ typedef uint32_t DWORD;
+ typedef int32_t LONG;
+-typedef int64_t INT64;
+-typedef uint64_t UINT64;
++typedef long long int INT64;
++typedef long long unsigned int UINT64;
+ #else
+ // MS is not C99 ISO compliant
+ typedef long BOOL;
diff --git a/vcpkg/ports/freeimage/vcpkg.json b/vcpkg/ports/freeimage/vcpkg.json
new file mode 100644
index 0000000..a4d10ce
--- /dev/null
+++ b/vcpkg/ports/freeimage/vcpkg.json
@@ -0,0 +1,35 @@
+{
+ "name": "freeimage",
+ "version": "3.18.0",
+ "port-version": 27,
+ "description": "Support library for graphics image formats",
+ "homepage": "https://sourceforge.net/projects/freeimage/",
+ "license": "GPL-2.0-only OR GPL-3.0-only OR FreeImage",
+ "dependencies": [
+ "imath",
+ "jxrlib",
+ "libjpeg-turbo",
+ "libpng",
+ "libraw",
+ {
+ "name": "libwebp",
+ "default-features": false,
+ "platform": "!uwp"
+ },
+ "openexr",
+ "openjpeg",
+ {
+ "name": "tiff",
+ "default-features": false
+ },
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ },
+ "zlib"
+ ]
+}