Skip to content

Commit 2cb404e

Browse files
authored
Merge pull request dials#100 from hattne/tiff
Refresh LibTIFF patches from conda-forge
2 parents 96c7986 + a9f39af commit 2cb404e

File tree

8 files changed

+17
-76
lines changed

8 files changed

+17
-76
lines changed

CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -644,16 +644,7 @@ set(CBF_WITH_LIBTIFF ON CACHE BOOL
644644
mark_as_advanced(CBF_WITH_LIBTIFF)
645645

646646
if(CBF_WITH_LIBTIFF)
647-
# The first LibTIFF at https://download.osgeo.org/libtiff with
648-
# native CMake support seems to be 4.0.5. The first version that
649-
# builds on current MSYS2 is 4.0.9.
650-
#
651-
# 4.0.3-rev-29Sep13 appears to have CMakeLists.txt patched in but
652-
# fails on MSYS2: multiple definition of ua_wcsicmp.
653-
#
654-
# 4.0.6_rev_3Nov16 fails on MSYS2: _FILE_OFFSET_BITS not defined
655-
#
656-
# 4.0.8 fails on MSYS2: _FILE_OFFSET_BITS
647+
# TIFFFieldSetGetSize() was introduced in LibTIFF 4.4.0
657648
set(tiff-contrib OFF CACHE INTERNAL "Build TIFF contrib")
658649
set(tiff-docs OFF CACHE INTERNAL "Build TIFF documentation")
659650
set(tiff-tests OFF CACHE INTERNAL "Build TIFF tests")
@@ -671,7 +662,7 @@ else()
671662
# cmake_pkg_config(), because e.g. Debian does not ship CMake config
672663
# files in their dev packages.
673664
find_package(PkgConfig REQUIRED)
674-
pkg_check_modules(tiff REQUIRED IMPORTED_TARGET libtiff-4>=4.0.10)
665+
pkg_check_modules(tiff REQUIRED IMPORTED_TARGET libtiff-4>=4.4.0)
675666
add_library(tiff ALIAS PkgConfig::tiff)
676667
endif()
677668

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2287,7 +2287,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
22872287
#
22882288
# cbf2tiff example program
22892289
#
2290-
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
2290+
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
22912291
$(GOPTLIB) $(GOPTINC) $(TIFF)
22922292
mkdir -p $(BIN)
22932293
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \

Makefile_LINUX

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
22832283
#
22842284
# cbf2tiff example program
22852285
#
2286-
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
2286+
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
22872287
$(GOPTLIB) $(GOPTINC) $(TIFF)
22882288
mkdir -p $(BIN)
22892289
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \

Makefile_MINGW

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
22972297
#
22982298
# cbf2tiff example program
22992299
#
2300-
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
2300+
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
23012301
$(GOPTLIB) $(GOPTINC) $(TIFF)
23022302
mkdir -p $(BIN)
23032303
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \

Makefile_MSYS2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
22832283
#
22842284
# cbf2tiff example program
22852285
#
2286-
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
2286+
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
22872287
$(GOPTLIB) $(GOPTINC) $(TIFF)
22882288
mkdir -p $(BIN)
22892289
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \

Makefile_OSX

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
22792279
#
22802280
# cbf2tiff example program
22812281
#
2282-
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
2282+
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
22832283
$(GOPTLIB) $(GOPTINC) $(TIFF)
22842284
mkdir -p $(BIN)
22852285
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \

examples/tif_sprint.c

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,6 @@ static const char *orientNames[] = {
7878
};
7979
#define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0]))
8080

81-
/*
82-
* Return data size of the field datatype in bytes. LibTIFF 4.4.0 introduced
83-
* TIFFFieldSetGetSize() for this.
84-
*/
85-
static int
86-
_TIFFFieldDataSize(const TIFFField *fip)
87-
{
88-
switch (TIFFFieldDataType(fip))
89-
{
90-
case TIFF_BYTE:
91-
case TIFF_SBYTE:
92-
case TIFF_ASCII:
93-
case TIFF_UNDEFINED:
94-
return 1;
95-
case TIFF_SHORT:
96-
case TIFF_SSHORT:
97-
return 2;
98-
case TIFF_LONG:
99-
case TIFF_SLONG:
100-
case TIFF_FLOAT:
101-
case TIFF_IFD:
102-
case TIFF_RATIONAL:
103-
case TIFF_SRATIONAL:
104-
return 4;
105-
case TIFF_DOUBLE:
106-
case TIFF_LONG8:
107-
case TIFF_SLONG8:
108-
case TIFF_IFD8:
109-
return 8;
110-
default:
111-
return 0;
112-
}
113-
}
114-
11581
static size_t
11682
_TIFFSNPrintField(char * str, const size_t xstrlen, const TIFFField *fip,
11783
uint32_t value_count, void *raw_data)
@@ -141,8 +107,8 @@ _TIFFSNPrintField(char * str, const size_t xstrlen, const TIFFField *fip,
141107
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "0x%" PRIx32, ((uint32_t *) raw_data)[j]);
142108
else if(TIFFFieldDataType(fip) == TIFF_RATIONAL
143109
|| TIFFFieldDataType(fip) == TIFF_SRATIONAL) {
144-
if (_TIFFFieldDataSize(fip) == 8)
145-
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%lf", ((double *)raw_data)[j]);
110+
if (TIFFFieldSetGetSize(fip) == 8)
111+
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%lf", ((double *) raw_data)[j]);
146112
else
147113
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%f", ((float *) raw_data)[j]);
148114
} else if(TIFFFieldDataType(fip) == TIFF_FLOAT)
@@ -289,8 +255,8 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
289255
size_t chars_used = 0;
290256

291257
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "TIFF Directory at offset 0x%" PRIx64 " (%" PRIu64 ")\n",
292-
TIFFCurrentDirOffset(tif),
293-
TIFFCurrentDirOffset(tif));
258+
TIFFCurrentDirOffset(tif),
259+
TIFFCurrentDirOffset(tif));
294260
if (!TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, &sampleinfo)) {
295261
extrasamples = 0;
296262
sampleinfo = NULL;
@@ -316,7 +282,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
316282
if (TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength)
317283
&& TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth)) {
318284
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " Image Width: %" PRIu32 " Image Length: %" PRIu32,
319-
imagewidth, imagelength);
285+
imagewidth, imagelength);
320286
if (TIFFGetField(tif, TIFFTAG_IMAGEDEPTH, &imagedepth))
321287
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " Image Depth: %" PRIu32,
322288
imagedepth);
@@ -450,7 +416,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
450416
cp = strchr(cp,'\0')+1, i--) {
451417
size_t max_chars =
452418
inknameslen - (cp - inknames);
453-
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0),sep);
419+
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%s", sep);
454420
chars_used += _TIFFsnprintAsciiBounded(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), cp, max_chars);
455421
sep = ", ";
456422
}
@@ -667,7 +633,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
667633
/*--: Rational2Double: For Rationals evaluate
668634
* "set_field_type" to determine internal storage size. */
669635
raw_data = _TIFFmalloc(
670-
_TIFFFieldDataSize(fip)
636+
TIFFFieldSetGetSize(fip)
671637
* value_count);
672638
mem_alloc = 1;
673639
if(TIFFGetField(tif, tag, raw_data) != 1) {
@@ -698,8 +664,8 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
698664
/* _TIFFFillStriles( tif ); */
699665

700666
if ((flags & TIFFPRINT_STRIPS) &&
701-
TIFFGetField(tif, TIFFTAG_STRIPOFFSETS, &stripoffsets) &&
702-
TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecounts)) {
667+
TIFFGetField(tif, TIFFTAG_STRIPOFFSETS, &stripoffsets) &&
668+
TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecounts)) {
703669
uint32_t s;
704670

705671
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " %" PRIu32 " %s:\n",
@@ -714,12 +680,6 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
714680
return chars_used;
715681
}
716682

717-
size_t
718-
_TIFFsnprintAscii(char * str, const size_t xstrlen, const char* cp)
719-
{
720-
return _TIFFsnprintAsciiBounded( str, xstrlen, cp, strlen(cp));
721-
}
722-
723683
static size_t
724684
_TIFFsnprintAsciiBounded(char * str, const size_t xstrlen, const char* cp, size_t max_chars)
725685
{
@@ -742,16 +702,6 @@ _TIFFsnprintAsciiBounded(char * str, const size_t xstrlen, const char* cp, size_
742702
return chars_used;
743703
}
744704

745-
size_t
746-
_TIFFsnprintAsciiTag(char * str, const size_t xstrlen, const char* name, const char* value)
747-
{
748-
size_t chars_used=0;
749-
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " %s: \"", name);
750-
chars_used += _TIFFsnprintAscii(str+chars_used, xstrlen, value);
751-
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "\"\n");
752-
return chars_used;
753-
}
754-
755705
/* vim: set ts=8 sts=8 sw=8 noet: */
756706
/*
757707
* Local Variables:

m4/Makefile.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2653,7 +2653,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
26532653
#
26542654
# cbf2tiff example program
26552655
#
2656-
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
2656+
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
26572657
$(GOPTLIB) $(GOPTINC) $(TIFF)
26582658
mkdir -p $(BIN)
26592659
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \

0 commit comments

Comments
 (0)