View | Details | Raw Unified | Return to bug 218681 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-39 / +32 lines)
Lines 2-12 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	freeimage
4
PORTNAME=	freeimage
5
PORTVERSION=	3.16.0
5
PORTVERSION=	3.17.0
6
PORTREVISION=	2
7
# Version 3.17.0 is available, but does not build on i386 (and probably
8
# other 32-bit arches) without some not-quite-trivial patching.  If one
9
# decides to update the port, please make sure 32-bit builds are tested!
10
CATEGORIES=	graphics
6
CATEGORIES=	graphics
11
MASTER_SITES=	SF/${PORTNAME}/Source%20Distribution/${PORTVERSION}
7
MASTER_SITES=	SF/${PORTNAME}/Source%20Distribution/${PORTVERSION}
12
DISTNAME=	FreeImage${PORTVERSION:S/.//g}
8
DISTNAME=	FreeImage${PORTVERSION:S/.//g}
Lines 14-62 Link Here
14
MAINTAINER=	ports@FreeBSD.org
10
MAINTAINER=	ports@FreeBSD.org
15
COMMENT=	Simple C/C++ bitmap graphics library
11
COMMENT=	Simple C/C++ bitmap graphics library
16
12
17
USES=		dos2unix gmake zip
13
LIB_DEPENDS=	libopenjp2.so:graphics/openjpeg	\
18
DOS2UNIX_FILES=	Source/LibOpenJPEG/opj_malloc.h \
14
		libpng16.so:graphics/png	\
19
		Source/LibRawLite/dcraw/dcraw.c \
15
		libraw.so:graphics/libraw	\
20
		Source/LibRawLite/internal/dcraw_common.cpp
16
		libtiff.so:graphics/tiff	\
17
		libwebp.so:graphics/webp	\
18
		libHalf.so:graphics/ilmbase	\
19
		libjxrglue.so:graphics/libjxr	\
20
		libIlmImf.so:graphics/OpenEXR
21
22
USES=		dos2unix jpeg pkgconfig uidfix zip
23
DOS2UNIX_FILES=	TestAPI/testJPEG.cpp TestAPI/MainTestSuite.cpp
21
USE_LDCONFIG=	yes
24
USE_LDCONFIG=	yes
22
WRKSRC=		${WRKDIR}/FreeImage
25
WRKSRC=		${WRKDIR}/FreeImage
23
MAKE_ARGS=	CC="${CC}" CPP="${CPP}" CXX="${CXX}"
24
26
25
CFLAGS+=	-fexceptions -fvisibility=hidden
27
# Do not even extract the the ancient versions of the
26
CFLAGS_aarch64=	-fPIC
28
# various dependencies -- rely on their ports instead:
27
CFLAGS_amd64=	-fPIC
29
EXCLUDE=	LibJPEG LibJXR LibOpenJPEG LibPNG LibRawLite LibTIFF4	\
30
		LibWebP OpenEXR ZLib
31
EXTRACT_AFTER_ARGS=	-a \
32
	${EXCLUDE:C,^(.*)$,-x FreeImage/Source/\1/* -x FreeImage/Source/\1,} \
33
	-x FreeImage/Wrapper/Delphi*	\
34
	-x FreeImage/Wrapper/FreeImage.NET*	\
35
	-x FreeImage/Wrapper/VB6*
28
36
29
PLIST_FILES=	include/FreeImage.h \
37
MAKEFILE=	${FILESDIR}/BSDmakefile
30
		include/FreeImagePlus.h \
31
		lib/libfreeimage.a \
32
		lib/libfreeimage-${PORTVERSION}.so \
33
		lib/libfreeimage.so.3 \
34
		lib/libfreeimage.so \
35
		lib/libfreeimageplus.a \
36
		lib/libfreeimageplus-${PORTVERSION}.so \
37
		lib/libfreeimageplus.so.3 \
38
		lib/libfreeimageplus.so
39
38
40
.include <bsd.port.options.mk>
39
.include <bsd.port.options.mk>
41
40
42
.if ${ARCH} == amd64 || ${ARCH} == powerpc
41
do-configure:
43
USES+=		compiler:c++0x
42
	${LN} -sf ${FILESDIR}/BSDmakefile.Source ${WRKSRC}/Source/BSDmakefile
44
.endif
43
	${LN} -sf ${FILESDIR}/BSDmakefile.FreeImagePlus ${WRKSRC}/Wrapper/FreeImagePlus/BSDmakefile
44
	${LN} -sf ${FILESDIR}/BSDmakefile.TestAPI ${WRKSRC}/TestAPI/BSDmakefile
45
45
46
post-patch:
46
post-patch:
47
	@${REINPLACE_CMD} -e 's|/usr|${PREFIX}| ; s|-o root -g root ||' \
47
	@${REINPLACE_CMD} -e 's|tiffiop.h|tiffio.h|'	\
48
		${WRKSRC}/Makefile.gnu ${WRKSRC}/Makefile.fip
48
		-e 's|#include *"\.\./.*/\([^/]*\)" *$$|#include <\1>|'	\
49
		${WRKSRC}/Source/*/*.[ch]*
49
50
50
post-build:
51
regression-test test check: build
51
	${SETENV} ${MAKE_ENV} ${MAKE_CMD} -f Makefile.fip ${_MAKE_JOBS} \
52
	# Complaints about "uknown tag" are considered Ok
52
		${MAKE_ARGS} -C ${BUILD_WRKSRC}
53
	cd ${WRKSRC}/TestAPI && ./testAPI
53
54
54
post-install:
55
	${SETENV} ${MAKE_ENV} ${MAKE_CMD} -f Makefile.fip ${MAKE_ARGS} \
56
		-C ${INSTALL_WRKSRC} ${INSTALL_TARGET}
57
	${LN} -sf libfreeimageplus.so.3 \
58
		${STAGEDIR}${PREFIX}/lib/libfreeimageplus.so
59
	${LN} -sf libfreeimageplus-${PORTVERSION}.so \
60
		${STAGEDIR}${PREFIX}/lib/libfreeimageplus.so.3
61
62
.include <bsd.port.mk>
55
.include <bsd.port.mk>
(-)distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (FreeImage3160.zip) = 03af32dd60140d07515ddfe7b4f467baa3b888a72ea78828811aded7adb42f60
1
TIMESTAMP = 1492192692
2
SIZE (FreeImage3160.zip) = 5669228
2
SHA256 (FreeImage3170.zip) = fbfc65e39b3d4e2cb108c4ffa8c41fd02c07d4d436c594fff8dab1a6d5297f89
3
SIZE (FreeImage3170.zip) = 7020636
(-)files/BSDmakefile (+5 lines)
Line 0 Link Here
1
SUBDIR=	Source
2
SUBDIR+=Wrapper/FreeImagePlus
3
SUBDIR+=TestAPI
4
5
.include <bsd.subdir.mk>
(-)files/BSDmakefile.FreeImagePlus (+18 lines)
Line 0 Link Here
1
LIB_CXX=	freeimageplus
2
SHLIB_MAJOR=	3
3
INCS=		FreeImagePlus.h
4
NO_PROFILE=	nope
5
6
LIBDIR=		${PREFIX}/lib
7
INCLUDEDIR=	${PREFIX}/include
8
9
SRCS=	FreeImagePlus.cpp fipImage.cpp fipMemoryIO.cpp fipMetadataFind.cpp \
10
	fipMultiPage.cpp fipTag.cpp
11
12
CXXFLAGS+=-I. -I${.CURDIR:H:H}/Source
13
14
LDADD=	-L${.CURDIR:H:H}/Source -lfreeimage
15
16
.PATH:	src
17
18
.include <bsd.lib.mk>
(-)files/BSDmakefile.Source (+37 lines)
Line 0 Link Here
1
LIB_CXX=	freeimage
2
SHLIB_MAJOR=	${VER_MAJOR}
3
INCS=		FreeImage.h
4
NO_PROFILE=	nope
5
6
LIBDIR=		${PREFIX}/lib
7
INCLUDEDIR=	${PREFIX}/include
8
9
.include "${.CURDIR:H}/Makefile.srcs"
10
11
SRCS:=	${SRCS:M*/Source/FreeImage*/*:T} ${SRCS:M*/Source/Metadata/*:T}	\
12
	${SRCS:M*/Source/DeprecationManager}
13
# Disable the plugins, which require access to internal structures of
14
# the other libraries. Similar thing is also done by Debian and Fedora...
15
SRCS:=	${SRCS:N*PluginG3.cpp}		# Requires TIFF internals
16
SRCS:=	${SRCS:N*JPEGTransform.cpp}	# Requires JPEG internals
17
18
OJPCFLAGS!=	pkgconf libopenjp2 --cflags
19
OJPLIBS!=	pkgconf libopenjp2 --libs
20
ILMLIBS!=	pkgconf IlmBase --libs
21
CXXFLAGS+=	-fexceptions -fvisibility=hidden
22
CXXFLAGS+=	-IDeprecationManager -IMetadata -I.
23
CXXFLAGS+=	-I${LOCALBASE}/include/OpenEXR
24
CXXFLAGS+=	-I${LOCALBASE}/include/libraw
25
CXXFLAGS+=	-I${LOCALBASE}/include/jxrlib
26
CXXFLAGS+=	-I${LOCALBASE}/include/webp
27
CXXFLAGS+=	${OJPCFLAGS}
28
CXXFLAGS+=	-I${LOCALBASE}/include -DOS_CODE=0x03
29
CXXFLAGS+=	-Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-switch -Wno-unused-value -Werror
30
CFLAGS+=	-I. -Werror
31
32
.PATH:	FreeImage FreeImageToolkit Metadata DeprecationMgr
33
34
LDADD=	-L${LOCALBASE}/lib
35
LDADD+=	-lopenjp2 -ljxrglue -ljpeg -lpng16 -lraw -ltiff -lwebpmux -lIlmImf -lHalf -lz
36
37
.include <bsd.lib.mk>
(-)files/BSDmakefile.TestAPI (+10 lines)
Line 0 Link Here
1
PROG_CXX=	testAPI
2
NO_MAN=		ha-ha
3
INTERNALPROG=	do not install
4
5
SRCS!=	echo *.cpp
6
7
CXXFLAGS+=-I${.CURDIR:H}/Source
8
LDADD=	-L${.CURDIR:H}/Source -Wl,-rpath=${.CURDIR:H}/Source -lfreeimage
9
10
.include <bsd.prog.mk>
(-)files/patch-CVE-2016-5684 (+31 lines)
Line 0 Link Here
1
From: Debian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
2
Date: Mon, 10 Oct 2016 08:22:44 +0100
3
Subject: CVE-2016-5684
4
5
---
6
 Source/FreeImage/PluginXPM.cpp | 7 ++++++-
7
 1 file changed, 6 insertions(+), 1 deletion(-)
8
9
--- Source/FreeImage/PluginXPM.cpp
10
+++ Source/FreeImage/PluginXPM.cpp
11
@@ -181,6 +181,11 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
12
 		}
13
 		free(str);
14
 
15
+		// check info string
16
+		if((width <= 0) || (height <= 0) || (colors <= 0) || (cpp <= 0)) {
17
+			throw "Improperly formed info string";
18
+		}
19
+
20
         if (colors > 256) {
21
 			dib = FreeImage_AllocateHeader(header_only, width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
22
 		} else {
23
@@ -193,7 +198,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
24
 			FILE_RGBA rgba;
25
 
26
 			str = ReadString(io, handle);
27
-			if(!str)
28
+			if(!str || (strlen(str) < (size_t)cpp))
29
 				throw "Error reading color strings";
30
 
31
 			std::string chrs(str,cpp); //create a string for the color chars using the first cpp chars
(-)files/patch-Disable-testing-of-JPEG-transform (+44 lines)
Line 0 Link Here
1
Adapted from Debian:
2
3
From: Ghislain Antony Vaillant <ghisvail@gmail.com>
4
Date: Tue, 3 Nov 2015 18:15:18 +0000
5
Subject: Disable testing of JPEG transform.
6
7
Reason: the JPEG transform features are disabled from the Debian build as a
8
result of the stripping of the vendored dependencies.
9
---
10
 TestAPI/testJPEG.cpp | 4 ++++
11
 1 file changed, 4 insertions(+)
12
13
diff --git a/TestAPI/testJPEG.cpp b/TestAPI/testJPEG.cpp
14
index 798033d..94638b9 100644
15
--- TestAPI/testJPEG.cpp
16
+++ TestAPI/testJPEG.cpp
17
@@ -25,6 +25,7 @@
18
 // Local test functions
19
 // ----------------------------------------------------------
20
 
21
+#if 0
22
 void testJPEGTransform(const char *src_file) {
23
 	BOOL bResult;
24
 	BOOL perfect;
25
@@ -193,11 +194,13 @@ void testJPEGSameFile(const char *src_file) {
26
 	bResult = FreeImage_JPEGTransform("test.jpg", "test.jpg", FIJPEG_OP_ROTATE_270, perfect);
27
 	assert(bResult);
28
 }
29
+#endif
30
 
31
 // Main test function
32
 // ----------------------------------------------------------
33
 
34
 void testJPEG() {
35
+#if 0
36
 	const char *src_file = "exif.jpg";
37
 
38
 	printf("testJPEG (should throw exceptions) ...\n");
39
@@ -213,4 +216,5 @@ void testJPEG() {
40
 
41
 	// using the same file for src & dst is allowed
42
 	testJPEGSameFile(src_file);
43
+#endif
44
 }
(-)files/patch-FreeImage.h (+19 lines)
Line 0 Link Here
1
--- Source/FreeImage.h	2015-03-04 02:17:54.000000000 -0500
2
+++ Source/FreeImage.h	2017-04-15 00:35:12.308397000 -0400
3
@@ -130,5 +130,4 @@
4
 
5
 #ifndef _WINDOWS_
6
-#define _WINDOWS_
7
 
8
 #ifndef FALSE
9
@@ -155,7 +154,9 @@
10
 typedef uint16_t WORD;
11
 typedef uint32_t DWORD;
12
-typedef int32_t LONG;
13
+typedef long LONG;
14
+#ifndef _LIBRAW_TYPES_H /* libraw defines these on its own -- differently */
15
 typedef int64_t INT64;
16
 typedef uint64_t UINT64;
17
+#endif
18
 #else
19
 // MS is not C99 ISO compliant
(-)files/patch-FreeImageTag.cpp (+9 lines)
Line 0 Link Here
1
--- Source/Metadata/FreeImageTag.cpp	2015-03-04 03:21:12.000000000 -0500
2
+++ Source/Metadata/FreeImageTag.cpp	2017-04-16 14:30:23.045403000 -0400
3
@@ -82,5 +82,5 @@
4
 FITAG * DLL_CALLCONV 
5
 FreeImage_CloneTag(FITAG *tag) {
6
-	if(!tag) return NULL;
7
+	if (!tag || !tag->data) return NULL;
8
 
9
 	// allocate a new tag
(-)files/patch-PluginDDS.cpp (+15 lines)
Line 0 Link Here
1
From https://sourceforge.net/p/freeimage/patches/121/
2
3
--- PluginDDS.cpp (1861)
4
+++ Source/FreeImage/PluginDDS.cpp (working copy)
5
@@ -399,8 +399,8 @@
6
 
7
 static FIBITMAP *
8
 LoadRGB (DDSURFACEDESC2 &desc, FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
9
-	int width = (int)desc.dwWidth & ~3;
10
-	int height = (int)desc.dwHeight & ~3;
11
+	int width = (int)desc.dwWidth;
12
+	int height = (int)desc.dwHeight;
13
 	int bpp = (int)desc.ddpfPixelFormat.dwRGBBitCount;
14
 	
15
 	// allocate a new dib
(-)files/patch-PluginTIFF.cpp (+236 lines)
Line 0 Link Here
1
Patch to bring up to the CVS-version
2
3
--- Source/FreeImage/PluginTIFF.cpp	2015-03-02 02:07:08.000000000 -0500
4
+++ Source/FreeImage/PluginTIFF.cpp	2017-04-16 15:10:18.458533000 -0400
5
@@ -104,6 +104,6 @@
6
 static BOOL tiff_read_iptc_profile(TIFF *tiff, FIBITMAP *dib);
7
 static BOOL tiff_read_xmp_profile(TIFF *tiff, FIBITMAP *dib);
8
-static BOOL tiff_read_exif_profile(TIFF *tiff, FIBITMAP *dib);
9
-static void ReadMetadata(TIFF *tiff, FIBITMAP *dib);
10
+static BOOL tiff_read_exif_profile(FreeImageIO *io, fi_handle handle, TIFF *tiff, FIBITMAP *dib);
11
+static void ReadMetadata(FreeImageIO *io, fi_handle handle, TIFF *tiff, FIBITMAP *dib);
12
 
13
 static BOOL tiff_write_iptc_profile(TIFF *tiff, FIBITMAP *dib);
14
@@ -214,4 +214,12 @@
15
 }
16
 
17
+void* 
18
+_TIFFcalloc(tmsize_t nmemb, tmsize_t siz) {
19
+	if (nmemb == 0 || siz == 0) {
20
+		return ((void *)NULL);
21
+	}
22
+	return calloc((size_t)nmemb, (size_t)siz);
23
+}
24
+
25
 void
26
 _TIFFfree(void *p) {
27
@@ -810,7 +818,7 @@
28
 */
29
 static BOOL 
30
-tiff_read_exif_profile(TIFF *tiff, FIBITMAP *dib) {
31
+tiff_read_exif_profile(FreeImageIO *io, fi_handle handle, TIFF *tiff, FIBITMAP *dib) {
32
 	BOOL bResult = FALSE;
33
-    toff_t exif_offset = 0;
34
+	toff_t exif_offset = 0;
35
 
36
 	// read EXIF-TIFF tags
37
@@ -820,11 +828,15 @@
38
 	if(TIFFGetField(tiff, TIFFTAG_EXIFIFD, &exif_offset)) {
39
 
40
+		const long tell_pos = io->tell_proc(handle);
41
+		const uint16 cur_dir = TIFFCurrentDirectory(tiff);
42
+
43
 		// read EXIF tags
44
-		if(!TIFFReadEXIFDirectory(tiff, exif_offset)) {
45
-			return FALSE;
46
+		if (TIFFReadEXIFDirectory(tiff, exif_offset)) {
47
+			// read all known exif tags
48
+			bResult = tiff_read_exif_tags(tiff, TagLib::EXIF_EXIF, dib);
49
 		}
50
 
51
-		// read all known exif tags
52
-		bResult = tiff_read_exif_tags(tiff, TagLib::EXIF_EXIF, dib);
53
+		io->seek_proc(handle, tell_pos, SEEK_SET);
54
+		TIFFSetDirectory(tiff, cur_dir);
55
 	}
56
 
57
@@ -836,5 +848,5 @@
58
 */
59
 static void 
60
-ReadMetadata(TIFF *tiff, FIBITMAP *dib) {
61
+ReadMetadata(FreeImageIO *io, fi_handle handle, TIFF *tiff, FIBITMAP *dib) {
62
 
63
 	// IPTC/NAA
64
@@ -848,5 +860,5 @@
65
 
66
 	// Exif-TIFF
67
-	tiff_read_exif_profile(tiff, dib);
68
+	tiff_read_exif_profile(io, handle, tiff, dib);
69
 }
70
 
71
@@ -1092,8 +1104,9 @@
72
 @param photometric TIFFTAG_PHOTOMETRIC tiff tag
73
 @param bitspersample TIFFTAG_BITSPERSAMPLE tiff tag
74
+@param samplesperpixel TIFFTAG_SAMPLESPERPIXEL tiff tag
75
 @return Returns FALSE if a uncommon bit-depth is encountered, returns TRUE otherwise
76
 */
77
 static BOOL 
78
-IsValidBitsPerSample(uint16 photometric, uint16 bitspersample) {
79
+IsValidBitsPerSample(uint16 photometric, uint16 bitspersample, uint16 samplesperpixel) {
80
 
81
 	switch(bitspersample) {
82
@@ -1118,4 +1131,7 @@
83
 			if((photometric == PHOTOMETRIC_MINISWHITE) || (photometric == PHOTOMETRIC_MINISBLACK) || (photometric == PHOTOMETRIC_LOGLUV)) { 
84
 				return TRUE;
85
+			} else if((photometric == PHOTOMETRIC_RGB) && (samplesperpixel == 3) || (samplesperpixel == 4)) {
86
+				// RGB[A]F
87
+				return TRUE;
88
 			} else {
89
 				return FALSE;
90
@@ -1222,22 +1238,22 @@
91
 ReadThumbnail(FreeImageIO *io, fi_handle handle, void *data, TIFF *tiff, FIBITMAP *dib) {
92
 	FIBITMAP* thumbnail = NULL;
93
-
94
+	
95
 	// read exif thumbnail (IFD 1) ...
96
-
97
-	uint32 exif_offset = 0;
98
+	
99
+	toff_t exif_offset = 0;
100
 	if(TIFFGetField(tiff, TIFFTAG_EXIFIFD, &exif_offset)) {
101
-
102
-		if(TIFFLastDirectory(tiff) != 0) {
103
+		
104
+		if(!TIFFLastDirectory(tiff)) {
105
 			// save current position
106
-			long tell_pos = io->tell_proc(handle);
107
-			uint16 cur_dir = TIFFCurrentDirectory(tiff);
108
-
109
+			const long tell_pos = io->tell_proc(handle);
110
+			const uint16 cur_dir = TIFFCurrentDirectory(tiff);
111
+			
112
 			// load the thumbnail
113
-			int page = 1; 
114
+			int page = 1;
115
 			int flags = TIFF_DEFAULT;
116
 			thumbnail = Load(io, handle, page, flags, data);
117
-			// store the thumbnail (remember to release it later ...)
118
+			// store the thumbnail (remember to release it before return)
119
 			FreeImage_SetThumbnail(dib, thumbnail);
120
-
121
+			
122
 			// restore current position
123
 			io->seek_proc(handle, tell_pos, SEEK_SET);
124
@@ -1245,17 +1261,20 @@
125
 		}
126
 	}
127
-
128
+	
129
 	// ... or read the first subIFD
130
-
131
+	
132
 	if(!thumbnail) {
133
 		uint16 subIFD_count = 0;
134
-		uint64* subIFD_offsets = NULL;
135
-		// ### Theoretically this should also read the first subIFD from a Photoshop-created file with "pyramid".
136
-		// It does not however - the tag is there (using Tag Viewer app) but libtiff refuses to read it
137
+		toff_t* subIFD_offsets = NULL;
138
+		
139
+		// This will also read the first (and only) subIFD from a Photoshop-created "pyramid" file.
140
+		// Subsequent, smaller images are 'nextIFD' in that subIFD. Currently we only load the first one. 
141
+		
142
 		if(TIFFGetField(tiff, TIFFTAG_SUBIFD, &subIFD_count, &subIFD_offsets)) {
143
 			if(subIFD_count > 0) {
144
 				// save current position
145
-				long tell_pos = io->tell_proc(handle);
146
-				uint16 cur_dir = TIFFCurrentDirectory(tiff);
147
+				const long tell_pos = io->tell_proc(handle);
148
+				const uint16 cur_dir = TIFFCurrentDirectory(tiff);
149
+				
150
 				if(TIFFSetSubDirectory(tiff, subIFD_offsets[0])) {
151
 					// load the thumbnail
152
@@ -1263,7 +1282,8 @@
153
 					int flags = TIFF_DEFAULT;
154
 					thumbnail = Load(io, handle, page, flags, data);
155
-					// store the thumbnail (remember to release it later ...)
156
+					// store the thumbnail (remember to release it before return)
157
 					FreeImage_SetThumbnail(dib, thumbnail);
158
 				}
159
+				
160
 				// restore current position
161
 				io->seek_proc(handle, tell_pos, SEEK_SET);
162
@@ -1274,15 +1294,15 @@
163
 	
164
 	// ... or read Photoshop thumbnail
165
-
166
+	
167
 	if(!thumbnail) {
168
 		uint32 ps_size = 0;
169
 		void *ps_data = NULL;
170
-
171
+		
172
 		if(TIFFGetField(tiff, TIFFTAG_PHOTOSHOP, &ps_size, &ps_data)) {
173
 			FIMEMORY *handle = FreeImage_OpenMemory((BYTE*)ps_data, ps_size);
174
-
175
+			
176
 			FreeImageIO io;
177
 			SetMemoryIO(&io);
178
-		
179
+			
180
 			psdParser parser;
181
 			parser.ReadImageResources(&io, handle, ps_size);
182
@@ -1292,7 +1312,6 @@
183
 			FreeImage_CloseMemory(handle);
184
 		}
185
-		
186
 	}
187
-
188
+	
189
 	// release thumbnail
190
 	FreeImage_Unload(thumbnail);
191
@@ -1366,5 +1385,5 @@
192
 		// ---------------------------------------------------------------------------------
193
 
194
-		if(IsValidBitsPerSample(photometric, bitspersample) == FALSE) {
195
+		if(IsValidBitsPerSample(photometric, bitspersample, samplesperpixel) == FALSE) {
196
 			FreeImage_OutputMessageProc(s_format_id, 
197
 				"Unable to handle this format: bitspersample = %d, samplesperpixel = %d, photometric = %d", 
198
@@ -2204,15 +2223,22 @@
199
 			throw FI_MSG_ERROR_UNSUPPORTED_FORMAT;
200
 		}
201
-
202
-		// copy ICC profile data (must be done after FreeImage_Allocate)
203
-
204
-		FreeImage_CreateICCProfile(dib, iccBuf, iccSize);		
205
-		if (photometric == PHOTOMETRIC_SEPARATED && asCMYK) {
206
-			FreeImage_GetICCProfile(dib)->flags |= FIICC_COLOR_IS_CMYK;
207
-		}			
208
-
209
+		
210
 		// copy TIFF metadata (must be done after FreeImage_Allocate)
211
 
212
-		ReadMetadata(tif, dib);
213
+		ReadMetadata(io, handle, tif, dib);
214
+
215
+		// copy ICC profile data (must be done after FreeImage_Allocate)
216
+		
217
+		FreeImage_CreateICCProfile(dib, iccBuf, iccSize);
218
+		if (photometric == PHOTOMETRIC_SEPARATED) {
219
+			if (asCMYK) {
220
+				// set the ICC profile as CMYK
221
+				FreeImage_GetICCProfile(dib)->flags |= FIICC_COLOR_IS_CMYK;
222
+			}
223
+			else {
224
+				// if original image is CMYK but is converted to RGB, remove ICC profile from Exif-TIFF metadata
225
+				FreeImage_SetMetadata(FIMD_EXIF_MAIN, dib, "InterColorProfile", NULL);
226
+			}
227
+		}
228
 
229
 		// copy TIFF thumbnail (must be done after FreeImage_Allocate)
230
@@ -2220,5 +2246,5 @@
231
 		ReadThumbnail(io, handle, data, tif, dib);
232
 
233
-		return (FIBITMAP *)dib;
234
+		return dib;
235
 
236
 	} catch (const char *message) {			
(-)files/patch-Source-OpenEXR-IlmImf_ImfAutoArray.h (-11 lines)
Lines 1-11 Link Here
1
--- Source/OpenEXR/IlmImf/ImfAutoArray.h.orig	2013-01-30 11:10:28.000000000 +0100
2
+++ Source/OpenEXR/IlmImf/ImfAutoArray.h	2013-01-30 12:05:10.000000000 +0100
3
@@ -46,6 +46,8 @@
4
 
5
 #include "OpenEXRConfig.h"
6
 
7
+#include <string.h>
8
+
9
 namespace Imf {
10
 
11
 
(-)files/patch-integer_overflow_ljpeg_start (-34 lines)
Lines 1-34 Link Here
1
Description: Fix integer overflow in the ljpeg_start function in dcraw
2
Author: Alex Tutubalin <lexa@lexa.ru>
3
Bug-Debian: https://bugs.debian.org/786790
4
Origin: https://github.com/LibRaw/LibRaw/commit/4606c28f494a750892c5c1ac7903e62dd1c6fdb5
5
	https://github.com/rawstudio/rawstudio/commit/983bda1f0fa5fa86884381208274198a620f006e
6
Bug: https://security-tracker.debian.org/tracker/CVE-2015-3885
7
Bug: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-3885
8
Reviewed-By: Anton Gladky <gladk@debian.org>
9
Last-Update: 2015-10-29
10
11
--- freeimage-3.15.4.orig/Source/LibRawLite/dcraw/dcraw.c
12
+++ Source/LibRawLite/dcraw/dcraw.c
13
@@ -768,7 +768,8 @@ struct jhead {
14
15
 int CLASS ljpeg_start (struct jhead *jh, int info_only)
16
 {
17
-  int c, tag, len;
18
+  int c, tag;
19
+  ushort len;
20
   uchar data[0x10000];
21
   const uchar *dp;
22
23
--- freeimage-3.15.4.orig/Source/LibRawLite/internal/dcraw_common.cpp
24
+++ Source/LibRawLite/internal/dcraw_common.cpp
25
@@ -630,7 +630,8 @@ void CLASS canon_compressed_load_raw()
26
27
 int CLASS ljpeg_start (struct jhead *jh, int info_only)
28
 {
29
-  int c, tag, len;
30
+  int c, tag;
31
+  ushort len;
32
   uchar data[0x10000];
33
   const uchar *dp;
34
(-)files/patch-jpeg (+13 lines)
Line 0 Link Here
1
--- Source/FreeImage/PluginJPEG.cpp	2015-03-02 02:07:08.000000000 -0500
2
+++ Source/FreeImage/PluginJPEG.cpp	2017-04-14 17:48:13.304868000 -0400
3
@@ -36,7 +36,7 @@
4
 #include <setjmp.h>
5
 
6
-#include "../LibJPEG/jinclude.h"
7
-#include "../LibJPEG/jpeglib.h"
8
-#include "../LibJPEG/jerror.h"
9
+#include <stdio.h>
10
+#include <jpeglib.h>
11
+#include <jerror.h>
12
 }
13
 
(-)files/patch-jpeg-cmyk (+76 lines)
Line 0 Link Here
1
--- Source/FreeImage/PluginJPEG.cpp	2015-03-02 02:07:08.000000000 -0500
2
+++ Source/FreeImage/PluginJPEG.cpp	2017-04-16 15:21:32.068749000 -0400
3
@@ -1128,6 +1128,7 @@
4
 SupportsExportDepth(int depth) {
5
 	return (
6
-			(depth == 8) ||
7
-			(depth == 24)
8
+			(depth == 8)  ||
9
+			(depth == 24) ||
10
+			(depth == 32)	// only if 32-bit CMYK
11
 		);
12
 }
13
@@ -1317,4 +1318,8 @@
14
 					}
15
 				}
16
+				
17
+				// if original image is CMYK but is converted to RGB, remove ICC profile from Exif-TIFF metadata
18
+				FreeImage_SetMetadata(FIMD_EXIF_MAIN, dib, "InterColorProfile", NULL);
19
+
20
 			} else if((cinfo.out_color_space == JCS_CMYK) && ((flags & JPEG_CMYK) == JPEG_CMYK)) {
21
 				// convert from LibJPEG CMYK to standard CMYK
22
@@ -1402,10 +1407,10 @@
23
 			// Check dib format
24
 
25
-			const char *sError = "only 24-bit highcolor or 8-bit greyscale/palette bitmaps can be saved as JPEG";
26
+			const char *sError = "only 24-bit RGB, 8-bit greyscale/palette or 32-bit CMYK bitmaps can be saved as JPEG";
27
 
28
 			FREE_IMAGE_COLOR_TYPE color_type = FreeImage_GetColorType(dib);
29
 			WORD bpp = (WORD)FreeImage_GetBPP(dib);
30
 
31
-			if ((bpp != 24) && (bpp != 8)) {
32
+			if ((bpp != 24) && (bpp != 8) && !(bpp == 32 && (color_type == FIC_CMYK))) {
33
 				throw sError;
34
 			}
35
@@ -1456,5 +1461,8 @@
36
 					cinfo.input_components = 1;
37
 					break;
38
-
39
+				case FIC_CMYK:
40
+					cinfo.in_color_space = JCS_CMYK;
41
+					cinfo.input_components = 4;
42
+					break;
43
 				default :
44
 					cinfo.in_color_space = JCS_RGB;
45
@@ -1600,4 +1608,31 @@
46
 				free(target);
47
 			}
48
+			else if(color_type == FIC_CMYK) {
49
+				unsigned pitch = FreeImage_GetPitch(dib);
50
+				BYTE *target = (BYTE*)malloc(pitch * sizeof(BYTE));
51
+				if (target == NULL) {
52
+					throw FI_MSG_ERROR_MEMORY;
53
+				}
54
+				
55
+				while (cinfo.next_scanline < cinfo.image_height) {
56
+					// get a copy of the scanline
57
+					memcpy(target, FreeImage_GetScanLine(dib, FreeImage_GetHeight(dib) - cinfo.next_scanline - 1), pitch);
58
+					
59
+					BYTE *target_p = target;
60
+					for(unsigned x = 0; x < cinfo.image_width; x++) {
61
+						// CMYK pixels are inverted
62
+						target_p[0] = ~target_p[0];	// C
63
+						target_p[1] = ~target_p[1];	// M
64
+						target_p[2] = ~target_p[2];	// Y
65
+						target_p[3] = ~target_p[3];	// K
66
+
67
+						target_p += 4;
68
+					}
69
+					
70
+					// write the scanline
71
+					jpeg_write_scanlines(&cinfo, &target, 1);
72
+				}
73
+				free(target);
74
+			}
75
 			else if(color_type == FIC_MINISBLACK) {
76
 				// 8-bit standard greyscale images
(-)files/patch-jxr (+11 lines)
Line 0 Link Here
1
--- Source/FreeImage/PluginJXR.cpp	2015-03-02 02:07:08.000000000 -0500
2
+++ Source/FreeImage/PluginJXR.cpp	2017-04-15 00:26:28.574254000 -0400
3
@@ -23,5 +23,6 @@
4
 #include "Utilities.h"
5
-#include "../Metadata/FreeImageTag.h"
6
+#include <FreeImageTag.h>
7
 
8
-#include "../LibJXR/jxrgluelib/JXRGlue.h"
9
+#define __ANSI__
10
+#include <JXRGlue.h>
11
 
(-)files/patch-nog3 (+22 lines)
Line 0 Link Here
1
Building the G3 plugin is of questionable utility, but
2
requires access to data not officially exported by libtiff.
3
4
Disable it...
5
6
	-mi
7
--- Source/FreeImage/Plugin.cpp	2015-03-02 02:07:08.000000000 -0500
8
+++ Source/FreeImage/Plugin.cpp	2017-04-15 01:11:48.347512000 -0400
9
@@ -39,5 +39,5 @@
10
 #include "Plugin.h"
11
 
12
-#include "../Metadata/FreeImageTag.h"
13
+#include <FreeImageTag.h>
14
 
15
 // =====================================================================
16
@@ -264,5 +264,5 @@
17
 	        s_plugins->AddNode(InitGIF);
18
 	        s_plugins->AddNode(InitHDR);
19
-			s_plugins->AddNode(InitG3);
20
+//			s_plugins->AddNode(InitG3);
21
 			s_plugins->AddNode(InitSGI);
22
 			s_plugins->AddNode(InitEXR);
(-)files/patch-png (+109 lines)
Line 0 Link Here
1
Based on:
2
3
	From: Ghislain Antony Vaillant <ghisvail@gmail.com>
4
	Date: Tue, 3 Nov 2015 15:20:45 +0000
5
	Subject: Fix compatibility with system libpng.
6
7
	[Ghislain Antony Vaillant]
8
	The PNG plugin of FreeImage makes use of optional features of libpng, which
9
	are not enabled in Debian. This commit adds the necessary guards for FreeImage
10
	to compile and run without these features.
11
12
	[Tobias Frost]
13
	Fix FTBFS with libpng 1.6.
14
15
--- Source/FreeImage/PluginPNG.cpp
16
+++ Source/FreeImage/PluginPNG.cpp
17
@@ -109,9 +109,11 @@ ReadMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) {
18
 			// create a tag
19
 			tag = FreeImage_CreateTag();
20
 			if(!tag) return FALSE;
21
-
22
+#ifdef PNG_iTXt_SUPPORTED
23
 			DWORD tag_length = (DWORD) MAX(text_ptr[i].text_length, text_ptr[i].itxt_length);
24
-
25
+#else
26
+			DWORD tag_length = text_ptr[i].text_length;
27
+#endif
28
 			FreeImage_SetTagLength(tag, tag_length);
29
 			FreeImage_SetTagCount(tag, tag_length);
30
 			FreeImage_SetTagType(tag, FIDT_ASCII);
31
@@ -179,14 +181,19 @@ WriteMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) {
32
 	if(mdhandle) {
33
 		do {
34
 			memset(&text_metadata, 0, sizeof(png_text));
35
+#ifdef PNG_iTXt_SUPPORTED
36
 			text_metadata.compression = 1;							// iTXt, none
37
+#else
38
+			text_metadata.compression = -1;
39
+#endif
40
 			text_metadata.key = (char*)FreeImage_GetTagKey(tag);	// keyword, 1-79 character description of "text"
41
 			text_metadata.text = (char*)FreeImage_GetTagValue(tag);	// comment, may be an empty string (ie "")
42
 			text_metadata.text_length = FreeImage_GetTagLength(tag);// length of the text string
43
+#ifdef PNG_iTXt_SUPPORTED
44
 			text_metadata.itxt_length = FreeImage_GetTagLength(tag);// length of the itxt string
45
 			text_metadata.lang = 0;		 // language code, 0-79 characters or a NULL pointer
46
 			text_metadata.lang_key = 0;	 // keyword translated UTF-8 string, 0 or more chars or a NULL pointer
47
-
48
+#endif
49
 			// set the tag 
50
 			png_set_text(png_ptr, info_ptr, &text_metadata, 1);
51
 
52
@@ -205,10 +212,11 @@ WriteMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) {
53
 		text_metadata.key = (char*)g_png_xmp_keyword;			// keyword, 1-79 character description of "text"
54
 		text_metadata.text = (char*)FreeImage_GetTagValue(tag);	// comment, may be an empty string (ie "")
55
 		text_metadata.text_length = FreeImage_GetTagLength(tag);// length of the text string
56
+#ifdef PNG_iTXt_SUPPORTED
57
 		text_metadata.itxt_length = FreeImage_GetTagLength(tag);// length of the itxt string
58
 		text_metadata.lang = 0;		 // language code, 0-79 characters or a NULL pointer
59
 		text_metadata.lang_key = 0;	 // keyword translated UTF-8 string, 0 or more chars or a NULL pointer
60
-
61
+#endif
62
 		// set the tag 
63
 		png_set_text(png_ptr, info_ptr, &text_metadata, 1);
64
 		bResult &= TRUE;
65
@@ -705,11 +713,19 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
66
 
67
 			if (png_get_valid(png_ptr, info_ptr, PNG_INFO_iCCP)) {
68
 				png_charp profile_name = NULL;
69
-				png_bytep profile_data = NULL;
70
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4 || PNG_LIBPNG_VER_MAJOR > 1
71
+				png_bytepp profile_data = NULL;
72
+#else
73
+				png_charp profile_data = NULL;
74
+#endif
75
 				png_uint_32 profile_length = 0;
76
 				int  compression_type;
77
 
78
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4 || PNG_LIBPNG_VER_MAJOR > 1
79
+				png_get_iCCP(png_ptr, info_ptr, &profile_name, &compression_type, profile_data, &profile_length);
80
+#else
81
 				png_get_iCCP(png_ptr, info_ptr, &profile_name, &compression_type, &profile_data, &profile_length);
82
+#endif
83
 
84
 				// copy ICC profile data (must be done after FreeImage_AllocateHeader)
85
 
86
@@ -744,8 +760,9 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
87
 			for (png_uint_32 k = 0; k < height; k++) {
88
 				row_pointers[height - 1 - k] = FreeImage_GetScanLine(dib, k);
89
 			}
90
-
91
+#ifdef PNG_BENIGN_ERRORS_SUPPORTED
92
 			png_set_benign_errors(png_ptr, 1);
93
+#endif
94
 			png_read_image(png_ptr, row_pointers);
95
 
96
 			// check if the bitmap contains transparency, if so enable it in the header
97
@@ -991,7 +1008,11 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
98
 
99
 			FIICCPROFILE *iccProfile = FreeImage_GetICCProfile(dib);
100
 			if (iccProfile->size && iccProfile->data) {
101
-				png_set_iCCP(png_ptr, info_ptr, "Embedded Profile", 0, (png_const_bytep)iccProfile->data, iccProfile->size);
102
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4 || PNG_LIBPNG_VER_MAJOR > 1
103
+				//png_set_iCCP(png_ptr, info_ptr, "Embedded Profile", 0, (png_const_bytep)iccProfile->data, iccProfile->size);
104
+#else
105
+				png_set_iCCP(png_ptr, info_ptr, "Embedded Profile", 0, (png_charp)iccProfile->data, iccProfile->size);
106
+#endif
107
 			}
108
 
109
 			// write metadata
(-)files/patch-raw-flags (+57 lines)
Line 0 Link Here
1
From: https://sourceforge.net/p/freeimage/patches/125/
2
3
--- Source/FreeImage/PluginRAW.cpp	2015-03-08 20:12:04.000000000 -0500
4
+++ Source/FreeImage/PluginRAW.cpp	2016-06-26 09:10:48.000000000 -0500
5
@@ -702,6 +702,31 @@
6
 		// (-h) outputs the image in 50% size
7
 		RawProcessor->imgdata.params.half_size = ((flags & RAW_HALFSIZE) == RAW_HALFSIZE) ? 1 : 0;
8
 
9
+		// Output Colorspace (-o [0-5]):
10
+		// raw: 
11
+		if ((flags & RAW_COLOR_RAW) == RAW_COLOR_RAW)    RawProcessor->imgdata.params.output_color = 0;
12
+		// sRGB D65:
13
+		if ((flags & RAW_COLOR_SRGB) == RAW_COLOR_SRGB)  RawProcessor->imgdata.params.output_color = 1;
14
+		// Adobe RGB (1998) D65:
15
+		if ((flags & RAW_COLOR_ADOBE) == RAW_COLOR_ADOBE)RawProcessor->imgdata.params.output_color = 2;
16
+		// Wide Gamut RGB D65:
17
+		if ((flags & RAW_COLOR_WIDE) == RAW_COLOR_WIDE) RawProcessor->imgdata.params.output_color = 3;
18
+		// Kodak ProPhoto RGB D65: 
19
+		if ((flags & RAW_COLOR_PROPHOTO) == RAW_COLOR_PROPHOTO) RawProcessor->imgdata.params.output_color = 4;
20
+		// XYZ:
21
+		if ((flags & RAW_COLOR_XYZ) == RAW_COLOR_XYZ) RawProcessor->imgdata.params.output_color = 5;
22
+
23
+		// Demosaic interpolation algorithm  (-q [0-3]):
24
+		// linear interpolatin: 
25
+		if ((flags & RAW_QUAL_LINEAR) == RAW_QUAL_LINEAR)    RawProcessor->imgdata.params.user_qual = 0;
26
+		// Variable Number of Gradients (VNG) interpolation:
27
+		if ((flags & RAW_QUAL_VNG) == RAW_QUAL_VNG)  RawProcessor->imgdata.params.user_qual = 1;
28
+		// Patterned Pixel Grouping (PPG) interpolation:
29
+		if ((flags & RAW_QUAL_PPG) == RAW_QUAL_PPG)RawProcessor->imgdata.params.user_qual = 2;
30
+		// Adaptive Homogeneity-Directed (AHD) interpolation:
31
+		if ((flags & RAW_QUAL_AHD) == RAW_QUAL_AHD) RawProcessor->imgdata.params.user_qual = 3;
32
+
33
+
34
 		// open the datastream
35
 		if(RawProcessor->open_datastream(&datastream) != LIBRAW_SUCCESS) {
36
 			throw "LibRaw : failed to open input stream (unknown format)";
37
diff -ur FreeImage3170.orig\Source\/FreeImage.h FreeImage3170.ggb\Source\/FreeImage.h
38
--- Source/FreeImage.h	2015-03-04 01:17:54.000000000 -0600
39
+++ Source/FreeImage.h	2016-06-26 08:48:10.000000000 -0500
40
@@ -737,6 +737,17 @@
41
 #define RAW_DISPLAY			2		//! load the file as RGB 24-bit
42
 #define RAW_HALFSIZE		4		//! output a half-size color image
43
 #define RAW_UNPROCESSED		8		//! output a FIT_UINT16 raw Bayer image
44
+#define RAW_COLOR_RAW	    0x0010		// raw colorspace
45
+#define RAW_COLOR_SRGB	    0x0020		// sRGB D65 colorspace
46
+#define RAW_COLOR_ADOBE	    0x0040		// Adobe RGB (1998) D65 colorspace
47
+#define RAW_COLOR_WIDE	    0x0080		// Wide Gamut RGB D65 colorspace
48
+#define RAW_COLOR_PROPHOTO  0x0100		// Kodak ProPhoto RGB D65 colorspace
49
+#define RAW_COLOR_XYZ	    0x0200		// XYZ colorspace
50
+#define RAW_COLOR_ACES	    0x0400		// ACES (in dcraw, not yet implemented in libraw)
51
+#define RAW_QUAL_LINEAR	    0x0800		// linear interpolation
52
+#define RAW_QUAL_VNG	    0x1000		// Variable Number of Gradients (VNG) interpolation
53
+#define RAW_QUAL_PPG	    0x2000		// Patterned Pixel Grouping (PPG) interpolation
54
+#define RAW_QUAL_AHD	    0x4000		// Adaptive Homogeneity-Directed (AHD) interpolation
55
 #define SGI_DEFAULT			0
56
 #define TARGA_DEFAULT       0
57
 #define TARGA_LOAD_RGB888   1       //! if set the loader converts RGB555 and ARGB8888 -> RGB888.
(-)files/patch-warnings (+239 lines)
Line 0 Link Here
1
--- Source/FreeImage/PluginGIF.cpp	2015-03-02 02:07:08.000000000 -0500
2
+++ Source/FreeImage/PluginGIF.cpp	2017-04-14 17:37:48.942939000 -0400
3
@@ -1028,5 +1028,5 @@
4
 				}
5
 				comment.append(1, '\0');
6
-				sprintf(buf, "Comment%d", idx);
7
+				sprintf(buf, "Comment%zu", idx);
8
 				DWORD comment_size = (DWORD)comment.size();
9
 				FreeImage_SetMetadataEx(FIMD_COMMENTS, dib, buf, 1, FIDT_ASCII, comment_size, comment_size, comment.c_str());
10
--- Source/FreeImage/PluginPICT.cpp	2015-03-02 02:07:08.000000000 -0500
11
+++ Source/FreeImage/PluginPICT.cpp	2017-04-14 19:51:56.531330000 -0400
12
@@ -959,5 +959,5 @@
13
 	try {		
14
 		// Skip empty 512 byte header.
15
-		if ( !io->seek_proc(handle, 512, SEEK_CUR) == 0 )
16
+		if (io->seek_proc(handle, 512, SEEK_CUR) != 0)
17
 			return NULL;
18
 		
19
--- Source/FreeImageToolkit/CopyPaste.cpp	2015-03-02 02:07:10.000000000 -0500
20
+++ Source/FreeImageToolkit/CopyPaste.cpp	2017-04-14 19:58:50.520119000 -0400
21
@@ -800,5 +800,5 @@
22
 	unsigned width = FreeImage_GetWidth(dib);
23
 	unsigned height = FreeImage_GetHeight(dib);
24
-	if (left < 0 || right > width || top < 0 || bottom > height) {
25
+	if (right > width || bottom > height) {
26
 		return NULL;
27
 	}
28
--- Source/Metadata/TagConversion.cpp	2015-03-02 02:07:10.000000000 -0500
29
+++ Source/Metadata/TagConversion.cpp	2017-04-15 16:02:39.025047000 -0400
30
@@ -39,4 +39,5 @@
31
 	static std::string buffer;
32
 	DWORD i;
33
+	const void *pv;
34
 
35
 	if(!tag)
36
@@ -49,14 +50,15 @@
37
 	FREE_IMAGE_MDTYPE tag_type = FreeImage_GetTagType(tag);
38
 	DWORD tag_count = FreeImage_GetTagCount(tag);
39
+	pv = FreeImage_GetTagValue(tag);
40
 
41
 	switch(tag_type) {
42
 		case FIDT_BYTE:		// N x 8-bit unsigned integer 
43
 		{
44
-			BYTE *pvalue = (BYTE*)FreeImage_GetTagValue(tag);
45
+			const uint8_t *pvalue = (const uint8_t *)pv;
46
 
47
-			sprintf(format, "%ld",	(LONG) pvalue[0]);
48
+			sprintf(format, "%u", (unsigned)pvalue[0]);
49
 			buffer += format;
50
 			for(i = 1; i < tag_count; i++) {
51
-				sprintf(format, " %ld",	(LONG) pvalue[i]);
52
+				sprintf(format, " %u", (unsigned)pvalue[i]);
53
 				buffer += format;
54
 			}
55
@@ -65,5 +67,5 @@
56
 		case FIDT_SHORT:	// N x 16-bit unsigned integer 
57
 		{
58
-			unsigned short *pvalue = (unsigned short *)FreeImage_GetTagValue(tag);
59
+			const uint16_t *pvalue = (const uint16_t *)pv;
60
 
61
 			sprintf(format, "%hu", pvalue[0]);
62
@@ -77,10 +79,10 @@
63
 		case FIDT_LONG:		// N x 32-bit unsigned integer 
64
 		{
65
-			DWORD *pvalue = (DWORD *)FreeImage_GetTagValue(tag);
66
+			const uint32_t *pvalue = (const uint32_t *)pv;
67
 
68
-			sprintf(format, "%lu", pvalue[0]);
69
+			sprintf(format, "%u", (unsigned)pvalue[0]);
70
 			buffer += format;
71
 			for(i = 1; i < tag_count; i++) {
72
-				sprintf(format, " %lu",	pvalue[i]);
73
+				sprintf(format, " %u",	(unsigned)pvalue[i]);
74
 				buffer += format;
75
 			}
76
@@ -89,10 +91,10 @@
77
 		case FIDT_RATIONAL: // N x 64-bit unsigned fraction 
78
 		{
79
-			DWORD *pvalue = (DWORD*)FreeImage_GetTagValue(tag);
80
+			const uint32_t *pvalue = (const uint32_t *)pv;
81
 
82
-			sprintf(format, "%ld/%ld", pvalue[0], pvalue[1]);
83
+			sprintf(format, "%lu/%lu", (unsigned long)pvalue[0], (unsigned long)pvalue[1]);
84
 			buffer += format;
85
 			for(i = 1; i < tag_count; i++) {
86
-				sprintf(format, " %ld/%ld", pvalue[2*i], pvalue[2*i+1]);
87
+				sprintf(format, " %lu/%lu", (unsigned long)pvalue[2*i], (unsigned long)pvalue[2*i+1]);
88
 				buffer += format;
89
 			}
90
@@ -101,10 +103,10 @@
91
 		case FIDT_SBYTE:	// N x 8-bit signed integer 
92
 		{
93
-			char *pvalue = (char*)FreeImage_GetTagValue(tag);
94
+			const int8_t *pvalue = (const int8_t *)pv;
95
 
96
-			sprintf(format, "%ld",	(LONG) pvalue[0]);
97
+			sprintf(format, "%d", (int)pvalue[0]);
98
 			buffer += format;
99
 			for(i = 1; i < tag_count; i++) {
100
-				sprintf(format, " %ld",	(LONG) pvalue[i]);
101
+				sprintf(format, " %d",	(int)pvalue[i]);
102
 				buffer += format;
103
 			}
104
@@ -113,10 +115,10 @@
105
 		case FIDT_SSHORT:	// N x 16-bit signed integer 
106
 		{
107
-			short *pvalue = (short *)FreeImage_GetTagValue(tag);
108
+			const int16_t *pvalue = (const int16_t *)pv;
109
 
110
-			sprintf(format, "%hd", pvalue[0]);
111
+			sprintf(format, "%hd", (short)pvalue[0]);
112
 			buffer += format;
113
 			for(i = 1; i < tag_count; i++) {
114
-				sprintf(format, " %hd",	pvalue[i]);
115
+				sprintf(format, " %hd",	(short)pvalue[i]);
116
 				buffer += format;
117
 			}
118
@@ -125,10 +127,10 @@
119
 		case FIDT_SLONG:	// N x 32-bit signed integer 
120
 		{
121
-			LONG *pvalue = (LONG *)FreeImage_GetTagValue(tag);
122
+			const int32_t *pvalue = (const int32_t *)pv;
123
 
124
-			sprintf(format, "%ld", pvalue[0]);
125
+			sprintf(format, "%ld", (long)pvalue[0]);
126
 			buffer += format;
127
 			for(i = 1; i < tag_count; i++) {
128
-				sprintf(format, " %ld",	pvalue[i]);
129
+				sprintf(format, " %ld",	(long)pvalue[i]);
130
 				buffer += format;
131
 			}
132
@@ -137,10 +139,10 @@
133
 		case FIDT_SRATIONAL:// N x 64-bit signed fraction 
134
 		{
135
-			LONG *pvalue = (LONG*)FreeImage_GetTagValue(tag);
136
+			const int64_t *pvalue = (const int64_t *)pv;
137
 
138
-			sprintf(format, "%ld/%ld", pvalue[0], pvalue[1]);
139
+			sprintf(format, "%ld/%ld", (long)pvalue[0], (long)pvalue[1]);
140
 			buffer += format;
141
 			for(i = 1; i < tag_count; i++) {
142
-				sprintf(format, " %ld/%ld", pvalue[2*i], pvalue[2*i+1]);
143
+				sprintf(format, " %ld/%ld", (long)pvalue[2*i], (long)pvalue[2*i+1]);
144
 				buffer += format;
145
 			}
146
@@ -149,5 +151,5 @@
147
 		case FIDT_FLOAT:	// N x 32-bit IEEE floating point 
148
 		{
149
-			float *pvalue = (float *)FreeImage_GetTagValue(tag);
150
+			const float *pvalue = (const float *)pv;
151
 
152
 			sprintf(format, "%f", (double) pvalue[0]);
153
@@ -161,5 +163,5 @@
154
 		case FIDT_DOUBLE:	// N x 64-bit IEEE floating point 
155
 		{
156
-			double *pvalue = (double *)FreeImage_GetTagValue(tag);
157
+			const double *pvalue = (const double *)pv;
158
 
159
 			sprintf(format, "%f", pvalue[0]);
160
@@ -173,10 +175,10 @@
161
 		case FIDT_IFD:		// N x 32-bit unsigned integer (offset) 
162
 		{
163
-			DWORD *pvalue = (DWORD *)FreeImage_GetTagValue(tag);
164
+			const uint32_t *pvalue = (const uint32_t *)pv;
165
 
166
-			sprintf(format, "%X", pvalue[0]);
167
+			sprintf(format, "%lX", (unsigned long)pvalue[0]);
168
 			buffer += format;
169
 			for(i = 1; i < tag_count; i++) {
170
-				sprintf(format, " %X",	pvalue[i]);
171
+				sprintf(format, " %lX",	(unsigned long)pvalue[i]);
172
 				buffer += format;
173
 			}
174
@@ -185,5 +187,5 @@
175
 		case FIDT_PALETTE:	// N x 32-bit RGBQUAD 
176
 		{
177
-			RGBQUAD *pvalue = (RGBQUAD *)FreeImage_GetTagValue(tag);
178
+			const RGBQUAD *pvalue = (const RGBQUAD *)pv;
179
 
180
 			sprintf(format, "(%d,%d,%d,%d)", pvalue[0].rgbRed, pvalue[0].rgbGreen, pvalue[0].rgbBlue, pvalue[0].rgbReserved);
181
@@ -198,10 +200,10 @@
182
 		case FIDT_LONG8:	// N x 64-bit unsigned integer 
183
 		{
184
-			UINT64 *pvalue = (UINT64 *)FreeImage_GetTagValue(tag);
185
+			const uint64_t *pvalue = (const uint64_t *)pv;
186
 
187
-			sprintf(format, "%ld", pvalue[0]);
188
+			sprintf(format, "%llu", (unsigned long long)pvalue[0]);
189
 			buffer += format;
190
 			for(i = 1; i < tag_count; i++) {
191
-				sprintf(format, "%ld", pvalue[i]);
192
+				sprintf(format, "%llu", (unsigned long long)pvalue[i]);
193
 				buffer += format;
194
 			}
195
@@ -211,10 +213,10 @@
196
 		case FIDT_IFD8:		// N x 64-bit unsigned integer (offset)
197
 		{
198
-			UINT64 *pvalue = (UINT64 *)FreeImage_GetTagValue(tag);
199
+			const uint64_t *pvalue = (const uint64_t *)pv;
200
 
201
-			sprintf(format, "%X", pvalue[0]);
202
+			sprintf(format, "%llX", (unsigned long long)pvalue[0]);
203
 			buffer += format;
204
 			for(i = 1; i < tag_count; i++) {
205
-				sprintf(format, "%X", pvalue[i]);
206
+				sprintf(format, "%llX", (unsigned long long)pvalue[i]);
207
 				buffer += format;
208
 			}
209
@@ -224,10 +226,10 @@
210
 		case FIDT_SLONG8:	// N x 64-bit signed integer
211
 		{
212
-			INT64 *pvalue = (INT64 *)FreeImage_GetTagValue(tag);
213
+			const int64_t *pvalue = (const int64_t *)pv;
214
 
215
-			sprintf(format, "%ld", pvalue[0]);
216
+			sprintf(format, "%lld", (long long)pvalue[0]);
217
 			buffer += format;
218
 			for(i = 1; i < tag_count; i++) {
219
-				sprintf(format, "%ld", pvalue[i]);
220
+				sprintf(format, "%lld", (long long)pvalue[i]);
221
 				buffer += format;
222
 			}
223
@@ -242,5 +244,5 @@
224
 			if(max_size == MAX_TEXT_EXTENT)
225
 				max_size--;
226
-			memcpy(format, (char*)FreeImage_GetTagValue(tag), max_size);
227
+			memcpy(format, pv, max_size);
228
 			format[max_size] = '\0';
229
 			buffer += format;
230
--- TestAPI/MainTestSuite.cpp	2015-02-25 09:08:38.000000000 -0500
231
+++ TestAPI/MainTestSuite.cpp	2017-04-15 01:18:24.712061000 -0400
232
@@ -35,6 +35,5 @@
233
 		printf("%s Format\n", FreeImage_GetFormatFromFIF(fif));
234
 	}
235
-	printf(message);
236
-	printf(" ***\n");
237
+	printf("%s ***\n", message);
238
 }
239
 
(-)files/patch-webp (+18 lines)
Line 0 Link Here
1
--- Source/FreeImage/PluginWebP.cpp	2015-03-02 02:07:08.000000000 -0500
2
+++ Source/FreeImage/PluginWebP.cpp	2017-04-15 00:38:52.407279000 -0400
3
@@ -23,10 +23,10 @@
4
 #include "Utilities.h"
5
 
6
-#include "../Metadata/FreeImageTag.h"
7
+#include <FreeImageTag.h>
8
 
9
-#include "../LibWebP/src/webp/decode.h"
10
-#include "../LibWebP/src/webp/encode.h"
11
-#include "../LibWebP/src/enc/vp8enci.h"
12
-#include "../LibWebP/src/webp/mux.h"
13
+#include <decode.h>
14
+#include <encode.h>
15
+
16
+#include <mux.h>
17
 
18
 // ==========================================================
(-)files/patch-xtiff (+125 lines)
Line 0 Link Here
1
Adapted from Debian:
2
	From: Ghislain Antony Vaillant <ghisvail@gmail.com>
3
	Date: Tue, 3 Nov 2015 14:39:33 +0000
4
	Subject: Disable vendored dependencies.
5
6
[...]
7
8
This patch is based on Fedora's FreeImage-3.17.0_unbundle patch.
9
--- Source/Metadata/XTIFF.cpp
10
+++ Source/Metadata/XTIFF.cpp
11
@@ -29,13 +29,18 @@
12
 #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
13
 #endif
14
 
15
-#include "../LibTIFF4/tiffiop.h"
16
+#include <tiffio.h>
17
 
18
 #include "FreeImage.h"
19
 #include "Utilities.h"
20
 #include "FreeImageTag.h"
21
 #include "FIRational.h"
22
 
23
+extern "C"
24
+{
25
+    int _TIFFDataSize(TIFFDataType type);
26
+}
27
+
28
 // ----------------------------------------------------------
29
 //   Extended TIFF Directory GEO Tag Support
30
 // ----------------------------------------------------------
31
@@ -224,6 +229,33 @@ tiff_write_geotiff_profile(TIFF *tif, FIBITMAP *dib) {
32
 //   TIFF EXIF tag reading & writing
33
 // ----------------------------------------------------------
34
 
35
+static uint32 exif_tag_ids[] = {
36
+  EXIFTAG_EXPOSURETIME, EXIFTAG_FNUMBER, EXIFTAG_EXPOSUREPROGRAM,
37
+  EXIFTAG_SPECTRALSENSITIVITY, EXIFTAG_ISOSPEEDRATINGS, EXIFTAG_OECF,
38
+  EXIFTAG_EXIFVERSION, EXIFTAG_DATETIMEORIGINAL, EXIFTAG_DATETIMEDIGITIZED,
39
+  EXIFTAG_COMPONENTSCONFIGURATION, EXIFTAG_COMPRESSEDBITSPERPIXEL,
40
+  EXIFTAG_SHUTTERSPEEDVALUE, EXIFTAG_APERTUREVALUE,
41
+  EXIFTAG_BRIGHTNESSVALUE, EXIFTAG_EXPOSUREBIASVALUE,
42
+  EXIFTAG_MAXAPERTUREVALUE, EXIFTAG_SUBJECTDISTANCE, EXIFTAG_METERINGMODE,
43
+  EXIFTAG_LIGHTSOURCE, EXIFTAG_FLASH, EXIFTAG_FOCALLENGTH,
44
+  EXIFTAG_SUBJECTAREA, EXIFTAG_MAKERNOTE, EXIFTAG_USERCOMMENT,
45
+  EXIFTAG_SUBSECTIME, EXIFTAG_SUBSECTIMEORIGINAL,
46
+  EXIFTAG_SUBSECTIMEDIGITIZED, EXIFTAG_FLASHPIXVERSION, EXIFTAG_COLORSPACE,
47
+  EXIFTAG_PIXELXDIMENSION, EXIFTAG_PIXELYDIMENSION,
48
+  EXIFTAG_RELATEDSOUNDFILE, EXIFTAG_FLASHENERGY,
49
+  EXIFTAG_SPATIALFREQUENCYRESPONSE, EXIFTAG_FOCALPLANEXRESOLUTION,
50
+  EXIFTAG_FOCALPLANEYRESOLUTION, EXIFTAG_FOCALPLANERESOLUTIONUNIT,
51
+  EXIFTAG_SUBJECTLOCATION, EXIFTAG_EXPOSUREINDEX, EXIFTAG_SENSINGMETHOD,
52
+  EXIFTAG_FILESOURCE, EXIFTAG_SCENETYPE, EXIFTAG_CFAPATTERN,
53
+  EXIFTAG_CUSTOMRENDERED, EXIFTAG_EXPOSUREMODE, EXIFTAG_WHITEBALANCE,
54
+  EXIFTAG_DIGITALZOOMRATIO, EXIFTAG_FOCALLENGTHIN35MMFILM,
55
+  EXIFTAG_SCENECAPTURETYPE, EXIFTAG_GAINCONTROL, EXIFTAG_CONTRAST,
56
+  EXIFTAG_SATURATION, EXIFTAG_SHARPNESS, EXIFTAG_DEVICESETTINGDESCRIPTION,
57
+  EXIFTAG_SUBJECTDISTANCERANGE, EXIFTAG_GAINCONTROL, EXIFTAG_GAINCONTROL,
58
+  EXIFTAG_IMAGEUNIQUEID
59
+};
60
+static int nExifTags = sizeof(exif_tag_ids) / sizeof(exif_tag_ids[0]);
61
+
62
 /**
63
 Read a single Exif tag
64
 
65
@@ -575,43 +607,10 @@ tiff_read_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) {
66
 
67
 	// loop over all Core Directory Tags
68
 	// ### uses private data, but there is no other way
69
+	// -> Fedora: Best we can do without private headers is to hard-code a list of known EXIF tags and read those
70
 	if(md_model == TagLib::EXIF_MAIN) {
71
-		const TIFFDirectory *td = &tif->tif_dir;
72
-
73
-		uint32 lastTag = 0;	//<- used to prevent reading some tags twice (as stored in tif_fieldinfo)
74
-
75
-		for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
76
-			const TIFFField *fld = tif->tif_fields[fi];
77
-
78
-			const uint32 tag_id = TIFFFieldTag(fld);
79
-
80
-			if(tag_id == lastTag) {
81
-				continue;
82
-			}
83
-
84
-			// test if tag value is set
85
-			// (lifted directly from LibTiff _TIFFWriteDirectory)
86
-
87
-			if( fld->field_bit == FIELD_CUSTOM ) {
88
-				int is_set = FALSE;
89
-
90
-				for(int ci = 0; ci < td->td_customValueCount; ci++ ) {
91
-					is_set |= (td->td_customValues[ci].info == fld);
92
-				}
93
-
94
-				if( !is_set ) {
95
-					continue;
96
-				}
97
-
98
-			} else if(!TIFFFieldSet(tif, fld->field_bit)) {
99
-				continue;
100
-			}
101
-
102
-			// process *all* other tags (some will be ignored)
103
-
104
-			tiff_read_exif_tag(tif, tag_id, dib, md_model);
105
-
106
-			lastTag = tag_id;
107
+		for (int i = 0; i < nExifTags; ++i) {
108
+			tiff_read_exif_tag(tif, exif_tag_ids[i], dib, md_model);
109
 		}
110
 
111
 	}
112
@@ -723,10 +722,9 @@ tiff_write_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) {
113
 	
114
 	TagLib& tag_lib = TagLib::instance();
115
 	
116
-	for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) {
117
-		const TIFFField *fld = tif->tif_fields[fi];
118
-		
119
-		const uint32 tag_id = TIFFFieldTag(fld);
120
+	for (int fi = 0, nfi = nExifTags; nfi > 0; nfi--, fi++) {
121
+		const uint32 tag_id = exif_tag_ids[fi];
122
+		const TIFFField *fld = TIFFFieldWithTag(tif, tag_id);
123
 
124
 		if(skip_write_field(tif, tag_id)) {
125
 			// skip tags that are already handled by the LibTIFF writing process
(-)files/patch-zutil (+14 lines)
Line 0 Link Here
1
Do not include zutil.h -- we only need it for OS_CODE and we simply
2
supply that #define on command-line...
3
--- Source/FreeImage/ZLibInterface.cpp	2015-03-02 02:07:10.000000000 -0500
4
+++ Source/FreeImage/ZLibInterface.cpp	2017-04-14 18:05:32.342316000 -0400
5
@@ -20,8 +20,7 @@
6
 // ==========================================================
7
 
8
-#include "../ZLib/zlib.h"
9
+#include <zlib.h>
10
 #include "FreeImage.h"
11
 #include "Utilities.h"
12
-#include "../ZLib/zutil.h"	/* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
13
 
14
 /**
(-)pkg-plist (+8 lines)
Line 0 Link Here
1
include/FreeImage.h
2
include/FreeImagePlus.h
3
lib/libfreeimage.a
4
lib/libfreeimage.so.3
5
lib/libfreeimage.so
6
lib/libfreeimageplus.a
7
lib/libfreeimageplus.so.3
8
lib/libfreeimageplus.so

Return to bug 218681