-
-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathTIFFTags.cpp
3243 lines (3225 loc) · 147 KB
/
TIFFTags.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/****************************************************************************
**
** NOTE THIS FILE ISN'T ACTUALLY USED by DeepSkyStacker, it is here because
** it contains lots of useful information.
** Copyright (C) 2023 David C. Partridge
** Based on FCam TIFFTags.cpp
** https://graphics.stanford.edu/papers/fcam/html/files.html
**
** BSD License Usage
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of DeepSkyStacker nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
**
****************************************************************************/
#include "stdafx.h"
#include <map>
#include <mutex>
#include "TIFFTags.h"
namespace TIFF
{
const TiffEntryInfo tiffEntryTypes[]
{
//// BASELINE TAGS
{
"Artist",
// Person who created the image.
TIFFTAG_ARTIST,
TIFF_ASCII
// Note: some older TIFF files used this tag for storing Copyright information.
},{
"BitsPerSample",
// Number of bits per component.
TIFFTAG_BITSPERSAMPLE,
TIFF_SHORT
// N = SamplesPerPixel
// Note that this field allows a different number of bits per component for each
// component corresponding to a pixel. For example, RGB color data could use a
// different number of bits per component for each of the three color planes. Most RGB
// files will have the same number of BitsPerSample for each component. Even in this
// case, the writer must write all three values.
// Default = 1. See also SamplesPerPixel.
//
// From DNG Spec:
// Supported values are from 8 to 32 bits/sample. The depth
// must be the same for each sample if SamplesPerPixel is not
// equal to 1. If BitsPerSample is not equal to 8 or 16 or 32,
// then the bits must be packed into bytes using the TIFF
// default FillOrder of 1 (big-endian), even if the TIFF file
// itself uses little-endian byte order.
},{
"CellLength",
// The length of the dithering or halftoning matrix used to create a dithered or
// halftoned bilevel file.
TIFFTAG_CELLLENGTH,
TIFF_SHORT
// N = 1
// This field should only be present if Threshholding = 2
// No default. See also Threshholding.
},{
"CellWidth",
// The width of the dithering or halftoning matrix used to create a dithered or
// halftoned bilevel file
TIFFTAG_CELLWIDTH,
TIFF_SHORT
// N = 1
// No default. See also Threshholding.
},{
"ColorMap",
// A color map for palette color images.
32,
TIFF_SHORT
// N = 3 * (2**BitsPerSample)
// This field defines a Red-Green-Blue color map (often called a lookup table) for
// palette-color images. In a palette-color image, a pixel value is used to index into
// an RGB lookup table. For example, a palette-color pixel having a value of 0
// would be displayed according to the 0th Red, Green, Blue triplet.
// In a TIFF ColorMap, all the Red values come first, followed by the Green values,
// then the Blue values. The number of values for each color is 2**BitsPerSample.
// Therefore, the ColorMap field for an 8-bit palette-color image would have 3 * 256
// values.
// The width of each value is 16 bits, as implied by the type of SHORT. 0 represents
// the minimum intensity, and 65535 represents the maximum intensity. Black is
// represented by 0,0,0, and white by 65535, 65535, 65535.
// See also PhotometricInterpretation—palette color.
// No default. ColorMap must be included in all palette-color images.
},{
"Compression",
// Compression scheme used on the image data.
TIFFTAG_COMPRESSION,
TIFF_SHORT
// N = 1
// 1 = No compression, but pack data into bytes as tightly as possible leaving no unused
// bits except at the end of a row.
// If Then the sample values are stored as an array of type:
// BitsPerSample = 16 for all samples SHORT
// BitsPerSample = 32 for all samples LONG
// Otherwise BYTE
// Each row is padded to the next BYTE/SHORT/LONG boundary, consistent with
// the preceding BitsPerSample rule.
// If the image data is stored as an array of SHORTs or LONGs, the byte ordering
// must be consistent with that specified in bytes 0 and 1 of the TIFF file header.
// Therefore, little-endian format files will have the least significant bytes preceding
// the most significant bytes, while big-endian format files will have the opposite
// order.
// If the number of bits per component is not a power of 2, and you are willing to give up
// some space for better performance, use the next higher power of 2. For example, if
// your data can be represented in 6 bits, set BitsPerSample to 8 instead of 6, and then
// convert the range of the values from [0,63] to [0,255].
// Rows must begin on byte boundaries. (SHORT boundaries if the data is stored as
// SHORTs, LONG boundaries if the data is stored as LONGs).
// Some graphics systems require image data rows to be word-aligned or double-word-
// aligned, and padded to word-boundaries or double-word boundaries. Uncompressed
// TIFF rows will need to be copied into word-aligned or double-word-aligned row
// buffers before being passed to the graphics routines in these environments.
// 2 = CCITT Group 3 1-Dimensional Modified Huffman run-length encoding. See
// Section 10. BitsPerSample must be 1, since this type of compression is defined
// only for bilevel images.
// 32773 = PackBits compression, a simple byte-oriented run-length scheme. See Section 9
// for details.
// Data compression applies only to the image data, pointed to by StripOffsets.
// Default = 1.
//
// From DNG Spec:
// Two Compression tag values are supported:
// Value = 1: Uncompressed data.
// Value = 7: JPEG compressed data, either baseline DCT JPEG, or lossless JPEG compression.
// If PhotometricInterpretation = 6 (YCbCr) and BitsPerSample
// = 8/8/8, or if PhotometricInterpretation = 1 (BlackIsZero)
// and BitsPerSample = 8, then the JPEG variant must be
// baseline DCT JPEG. Otherwise, the JPEG variant must be
// lossless Huffman JPEG. For lossless JPEG, the internal
// width/length/components in the JPEG stream are not required
// to match the strip or tile's width/length/components. Only
// the total sample counts need to match. It is common for CFA
// images to be encoded with a different width, length or
// component count to allow the JPEG compression predictors to
// work across like colors.
},{
"Copyright",
// Copyright notice.
TIFFTAG_COPYRIGHT,
TIFF_ASCII
// Copyright notice of the person or organization that claims the copyright to the
// image. The complete copyright statement should be listed in this field including
// any dates and statements of claims. For example, “Copyright, John Smith, 19xx.
// All rights reserved.”
},{
"DateTime",
// Date and time of image creation.
TIFFTAG_DATETIME,
TIFF_ASCII
// N = 20
// The format is: “YYYY:MM:DD HH:MM:SS”, with hours like those on a 24-hour
// clock, and one space character between the date and the time. The length of the
// string, including the terminating NUL, is 20 bytes.
},{
"ExtraSamples",
// Description of extra components.
TIFFTAG_EXTRASAMPLES,
TIFF_SHORT
// N = m
// Specifies that each pixel has m extra components whose interpretation is defined
// by one of the values listed below. When this field is used, the SamplesPerPixel
// field has a value greater than the PhotometricInterpretation field suggests.
// For example, full-color RGB data normally has SamplesPerPixel=3. If
// SamplesPerPixel is greater than 3, then the ExtraSamples field describes the
// meaning of the extra samples. If SamplesPerPixel is, say, 5 then ExtraSamples
// will contain 2 values, one for each extra sample.
// ExtraSamples is typically used to include non-color information, such as opacity,
// in an image. The possible values for each item in the field's value are:
// 0 = Unspecified data
// 1 = Associated alpha data (with pre-multiplied color)
// 2 = Unassociated alpha data
// Associated alpha data is opacity information; it is fully described in Section 21.
// Unassociated alpha data is transparency information that logically exists indepen-
// dent of an image; it is commonly called a soft matte. Note that including both
// unassociated Land associated alpha is undefined because associated alpha specifies
// that color components are pre-multiplied by the alpha component, while
// unassociated alpha specifies the opposite.
// By convention, extra components that are present must be stored as the “last com-
// ponents” in each pixel. For example, if SamplesPerPixel is 4 and there is 1 extra
// component, then it is located in the last component location (SamplesPerPixel-1)
// in each pixel.
// Components designated as “extra” are just like other components in a pixel. In
// particular, the size of such components is defined by the value of the
// BitsPerSample field.
// With the introduction of this field, TIFF readers must not assume a particular
// SamplesPerPixel value based on the value of the PhotometricInterpretation field.
// For example, if the file is an RGB file, SamplesPerPixel may be greater than 3.
// The default is no extra samples. This field must be present if there are extra
// samples.
// See also SamplesPerPixel, AssociatedAlpha.
},{
"FillOrder",
// The logical order of bits within a byte.
TIFFTAG_FILLORDER,
TIFF_SHORT
// N = 1
// 1 = pixels are arranged within a byte such that pixels with lower column values are
// stored in the higher-order bits of the byte.
// 1-bit uncompressed data example: Pixel 0 of a row is stored in the high-order bit
// of byte 0, pixel 1 is stored in the next-highest bit, ..., pixel 7 is stored in the low-
// order bit of byte 0, pixel 8 is stored in the high-order bit of byte 1, and so on.
// CCITT 1-bit compressed data example: The high-order bit of the first compres-
// sion code is stored in the high-order bit of byte 0, the next-highest bit of the first
// compression code is stored in the next-highest bit of byte 0, and so on.
// 2 = pixels are arranged within a byte such that pixels with lower column values are
// stored in the lower-order bits of the byte.
// We recommend that FillOrder=2 be used only in special-purpose applications. It
// is easy and inexpensive for writers to reverse bit order by using a 256-byte lookup
// table1 and the data is
// either uncompressed or compressed using CCITT 1D or 2D compression, to
// avoid potentially ambigous situations.
// Support for FillOrder=2 is not required in a Baseline TIFF compliant reader
// Default is FillOrder = 1.
// FreeByteCounts
// For each string of contiguous unused bytes in a TIFF file, the number of bytes in
// the string.
// Tag = 289 (121.H)
// Type = LONG
// Not recommended for general interchange.
// See also FreeOffsets.
},{
"FreeOffsets",
// For each string of contiguous unused bytes in a TIFF file, the byte offset of the
// string.
TIFFTAG_FREEOFFSETS,
TIFF_LONG
// Not recommended for general interchange.
// See also FreeByteCounts.
},{
"GrayResponseCurve",
// For grayscale data, the optical density of each possible pixel value.
TIFFTAG_GRAYRESPONSECURVE,
TIFF_SHORT
// N = 2**BitsPerSample
// The 0th value of GrayResponseCurve corresponds to the optical density of a pixel
// having a value of 0, and so on.
// This field may provide useful information for sophisticated applications, but it is
// currently ignored by most TIFF readers.
// See also GrayResponseUnit, PhotometricInterpretation.
},{
"GrayResponseUnit",
// The precision of the information contained in the GrayResponseCurve.
TIFFTAG_GRAYRESPONSEUNIT,
TIFF_SHORT
// N = 1
// Because optical density is specified in terms of fractional numbers, this field is
// necessary to interpret the stored integer information. For example, if
// GrayScaleResponseUnits is set to 4 (ten-thousandths of a unit), and a
// GrayScaleResponseCurve number for gray level 4 is 3455, then the resulting
// actual value is 0.3455.
// Optical densitometers typically measure densities within the range of 0.0 to 2.0.
// 1 = Number represents tenths of a unit.
// 2 = Number represents hundredths of a unit.
// 3 = Number represents thousandths of a unit.
// 4 = Number represents ten-thousandths of a unit.
// 5 = Number represents hundred-thousandths of a unit.
// Modifies GrayResponseCurve.
// See also GrayResponseCurve.
// For historical reasons, the default is 2. However, for greater accuracy, 3 is recom-
// mended.
},{
"HostComputer",
// The computer and/or operating system in use at the time of image creation.
TIFFTAG_HOSTCOMPUTER,
TIFF_ASCII
// See also Make, Model, Software.
},{
"ImageDescription",
// A string that describes the subject of the image.
TIFFTAG_IMAGEDESCRIPTION,
TIFF_ASCII
// For example, a user may wish to attach a comment such as “1988 company pic-
// nic” to an image.
},{
"ImageLength",
// The number of rows of pixels in the image.
TIFFTAG_IMAGELENGTH,
TIFF_LONG // or SHORT
// N = 1
// No default. See also ImageWidth.
},{
"ImageWidth",
// The number of columns in the image, i.e., the number of pixels per row.
TIFFTAG_IMAGEWIDTH,
TIFF_LONG // or SHORT
// N = 1
// No default. See also ImageLength.
},{
"Make",
// The scanner manufacturer.
TIFFTAG_MAKE,
TIFF_ASCII
// Manufacturer of the scanner, video digitizer, or other type of equipment used to
// generate the image. Synthetic images should not include this field.
// See also Model, Software.
},{
"MaxSampleValue",
// The maximum component value used.
TIFFTAG_MAXSAMPLEVALUE,
TIFF_SHORT
// N = SamplesPerPixel
// This field is not to be used to affect the visual appearance of an image when it is
// displayed or printed. Nor should this field affect the interpretation of any other
// field; it is used only for statistical purposes.
// Default is 2**(BitsPerSample) - 1.
},{
"MinSampleValue",
// The minimum component value used.
TIFFTAG_MINSAMPLEVALUE,
TIFF_SHORT
// N = SamplesPerPixel
// See also MaxSampleValue.
// Default is 0.
},{
"Model",
// The scanner model name or number.
TIFFTAG_MODEL,
TIFF_ASCII
// The model name or number of the scanner, video digitizer, or other type of equip-
// ment used to generate the image.
// See also Make, Software.
},{
"NewSubfileType",
// A general indication of the kind of data contained in this subfile.
TIFFTAG_SUBFILETYPE,
TIFF_LONG
// N = 1 Replaces the old SubfileType field, due to
// limitations in the definition of that field.
// NewSubfileType is mainly useful when there are multiple
// subfiles in a single TIFF file. This field is made up of a
// set of 32 flag bits. Unused bits are expected to be 0. Bit
// 0 is the low-order bit. Currently defined values are: Bit
// 0 is 1 if the image is a reduced-resolution version of
// another image in this TIFF file; else the bit is 0. Bit 1
// is 1 if the image is a single page of a multi-page image
// (see the PageNumber field description); else the bit is 0.
// Bit 2 is 1 if the image defines a transparency mask for
// another image in this TIFF file. The
// PhotometricInterpretation value must be 4, designating a
// transparency mask. These values are defined as bit flags
// because they are independent of each other. Default is 0.
//
// From DNG Spec: In DNG versions earlier than 1.2.0.0, full
// resolution raw images should use NewSubFileType equal to
// 0. Rendered previews or reduced resolution versions of raw
// images should use NewSubFileType equal to 1. DNG 1.2.0.0
// allows a new value for NewSubFileType equal to
// 10001.H. This value, used for alternative or non-primary
// rendered previews, allows for multiple renderings (not just
// multiple sizes of a single rendering) to be stored in a DNG
// file. DNG reading software that displays a preview for a
// DNG file should, by default, display a preview from an IFD
// with NewSubFileType equal to 1. Alternative renderings
// should only be displayed if requested by the user.
},{
"Orientation",
// The orientation of the image with respect to the rows and columns.
TIFFTAG_ORIENTATION,
TIFF_SHORT
// N = 1
// 1 = The 0th row represents the visual top of the image, and the 0th column represents
// the visual left-hand side.
// 2 = The 0th row represents the visual top of the image, and the 0th column represents
// the visual right-hand side.
// 3 = The 0th row represents the visual bottom of the image, and the 0th column repre-
// sents the visual right-hand side.
// 4 = The 0th row represents the visual bottom of the image, and the 0th column repre-
// sents the visual left-hand side.
// 5 = The 0th row represents the visual left-hand side of the image, and the 0th column
// represents the visual top.
// 6 = The 0th row represents the visual right-hand side of the image, and the 0th column
// represents the visual top.
// 7 = The 0th row represents the visual right-hand side of the image, and the 0th column
// represents the visual bottom.
// 8 = The 0th row represents the visual left-hand side of the image, and the 0th column
// represents the visual bottom.
// Default is 1.
// Support for orientations other than 1 is not a Baseline TIFF requirement.
//
// From DNG spec:
// Orientation is a required tag for DNG. With the Orientation
// tag present, file browsers can perform lossless rotation of
// DNG files by modifying a single byte of the file. DNG
// readers should support all possible orientations, including
// mirrored orientations. Note that the mirrored orientations
// are not allowed by the TIFF-EP specification, so writers
// should not use them if they want their files be compatible
// with both specifications.
},{
"PhotometricInterpretation",
// The color space of the image data.
TIFFTAG_PHOTOMETRIC,
TIFF_SHORT
// N = 1
// 0 = WhiteIsZero. For bilevel and grayscale images: 0 is imaged as white.
// 2**BitsPerSample-1 is imaged as black. This is the normal value for Compres-
// sion=2.
// 1 = BlackIsZero. For bilevel and grayscale images: 0 is imaged as black.
// 2**BitsPerSample-1 is imaged as white. If this value is specified for Compres-
// sion=2, the image should display and print reversed.
// 2 = RGB. In the RGB model, a color is described as a combination of the three pri-
// mary colors of light (red, green, and blue) in particular concentrations. For each of
// the three components, 0 represents minimum intensity, and 2**BitsPerSample - 1
// represents maximum intensity. Thus an RGB value of (0,0,0) represents black,
// and (255,255,255) represents white, assuming 8-bit components. For
// PlanarConfiguration = 1, the components are stored in the indicated order: first
// Red, then Green, then Blue2, the StripOffsets for the
// component planes are stored in the indicated order: first the Red component plane
// StripOffsets, then the Green plane StripOffsets, then the Blue plane StripOffsets.
// 3= Palette color. In this model, a color is described with a single component. The
// value of the component is used as an index into the red, green and blue curves in
// the ColorMap field to retrieve an RGB triplet that defines the color. When
// PhotometricInterpretation=3 is used, ColorMap must be present and
// SamplesPerPixel must be 1.
// 4 = Transparency Mask.
// This means that the image is used to define an irregularly shaped region of another
// image in the same TIFF file. SamplesPerPixel and BitsPerSample must be 1.
// PackBits compression is recommended. The 1-bits define the interior of the re-
// gion; the 0-bits define the exterior of the region.
// A reader application can use the mask to determine which parts of the image to
// display. Main image pixels that correspond to 1-bits in the transparency mask are
// imaged to the screen or printer, but main image pixels that correspond to 0-bits in
// the mask are not displayed or printed.
// The image mask is typically at a higher resolution than the main image, if the
// main image is grayscale or color so that the edges can be sharp.
// There is no default for PhotometricInterpretation, and it is required. Do not rely
// on applications defaulting to what you want.
//
// From DNG Spec:
// The following values are supported for thumbnail and preview IFDs only:
// 1 = BlackIsZero. Assumed to be in a gamma 2.2 color space, unless otherwise specified using PreviewColorSpace tag.
// 2 = RGB. Assumed to be in the sRGB color space, unless otherwise specified using the PreviewColorSpace tag.
// 6 = YCbCr. Used for JPEG encoded preview images.
// The following values are supported for the raw IFD, and are assumed to be the camera's native color space:
// 32803 = CFA (Color Filter Array).
// 34892 = LinearRaw.
// The CFA PhotometricInterpretation value is documented in
// the TIFF-EP specification. Its use requires the use of the
// CFARepeatPatternDim and CFAPattern tags in the same
// IFD. The origin of the repeating CFA pattern is the
// top-left corner of the ActiveArea rectangle. The LinearRaw
// PhotometricInterpretation value is intended for use by
// cameras that do not use color filter arrays, but instead
// capture all color components at each pixel. It can also be
// used for CFA data that has already been de-mosaiced. The
// LinearRaw value can be used in reduced resolution IFDs,
// even if the raw IFD uses the CFA PhotometricInterpretation
// value.
},{
"PlanarConfiguration",
// How the components of each pixel are stored.
TIFFTAG_PLANARCONFIG,
TIFF_SHORT
// N = 1
// 1 = Chunky format. The component values for each pixel are stored contiguously.
// The order of the components within the pixel is specified by
// PhotometricInterpretation. For example, for RGB data, the data is stored as
// RGBRGBRGB…
// 2 = Planar format. The components are stored in separate “component planes.” The
// values in StripOffsets and StripByteCounts are then arranged as a 2-dimensional
// array, with SamplesPerPixel rows and StripsPerImage columns. (All of the col-
// umns for row 0 are stored first, followed by the columns of row 1, and so on.)
// PhotometricInterpretation describes the type of data stored in each component
// plane. For example, RGB data is stored with the Red components in one compo-
// nent plane, the Green in another, and the Blue in another.
// PlanarConfiguration=2 is not currently in widespread use and it is not recom-
// mended for general interchange. It is used as an extension and Baseline TIFF
// readers are not required to support it.
// If SamplesPerPixel is 1, PlanarConfiguration is irrelevant, and need not be in-
// cluded.
// If a row interleave effect is desired, a writer might write out the data as
// PlanarConfiguration=2—separate sample planes—but break up the planes into
// multiple strips (one row per strip, perhaps) and interleave the strips.
// Default is 1. See also BitsPerSample, SamplesPerPixel.
},{
"ResolutionUnit",
// The unit of measurement for XResolution and YResolution.
TIFFTAG_RESOLUTIONUNIT,
TIFF_SHORT
// N = 1
// To be used with XResolution and YResolution.
// 1 = No absolute unit of measurement. Used for images that may have a non-square
// aspect ratio, but no meaningful absolute dimensions.
// The drawback of ResolutionUnit=1 is that different applications will import the image
// at different sizes. Even if the decision is arbitrary, it might be better to use dots per
// inch or dots per centimeter, and to pick XResolution and YResolution so that the
// aspect ratio is correct and the maximum dimension of the image is about four inches
// (the “four” is arbitrary.)
// 2 = Inch.
// 3 = Centimeter.
// Default is 2.
},{
"RowsPerStrip",
// The number of rows per strip.
TIFFTAG_ROWSPERSTRIP,
TIFF_LONG // or SHORT
// N = 1
// TIFF image data is organized into strips for faster random access and efficient I/O
// buffering.
// RowsPerStrip and ImageLength together tell us the number of strips in the entire
// image. The equation is:
// StripsPerImage = floor ((ImageLength + RowsPerStrip - 1) / RowsPerStrip).
// StripsPerImage is not a field. It is merely a value that a TIFF reader will want to
// compute because it specifies the number of StripOffsets and StripByteCounts for the
// image.
// Note that either SHORT or LONG values can be used to specify RowsPerStrip.
// SHORT values may be used for small TIFF files. It should be noted, however, that
// earlier TIFF specification revisions required LONG values and that some software
// may not accept SHORT values.
// The default is 2**32 - 1, which is effectively infinity. That is, the entire image is
// one strip.
// Use of a single strip is not recommended. Choose RowsPerStrip such that each strip is
// about 8K bytes, even if the data is not compressed, since it makes buffering simpler
// for readers. The “8K” value is fairly arbitrary, but seems to work well.
// See also ImageLength, StripOffsets, StripByteCounts, TileWidth, TileLength,
// TileOffsets, TileByteCounts.
},{
"SamplesPerPixel",
// The number of components per pixel.
TIFFTAG_SAMPLESPERPIXEL,
TIFF_SHORT
// N = 1
// SamplesPerPixel is usually 1 for bilevel, grayscale, and palette-color images.
// SamplesPerPixel is usually 3 for RGB images.
// Default = 1. See also BitsPerSample, PhotometricInterpretation, ExtraSamples.
},{
"Software",
// Name and version number of the software package(s) used to create the image.
TIFFTAG_SOFTWARE,
TIFF_ASCII
// See also Make, Model.
},{
"StripByteCounts",
// For each strip, the number of bytes in the strip after compression.
TIFFTAG_STRIPBYTECOUNTS,
TIFF_LONG // or SHORT, but make sure to write LONG
// N = StripsPerImage for PlanarConfiguration equal to 1.
// = SamplesPerPixel * StripsPerImage for PlanarConfiguration equal to 2
// This tag is required for Baseline TIFF files.
// No default.
// See also StripOffsets, RowsPerStrip, TileOffsets, TileByteCounts.
},{
"StripOffsets",
// For each strip, the byte offset of that strip.
TIFFTAG_STRIPOFFSETS,
TIFF_LONG // or SHORT, but make sure to write LONG
// N = StripsPerImage for PlanarConfiguration equal to 1.
// = SamplesPerPixel * StripsPerImage for PlanarConfiguration equal to 2
// The offset is specified with respect to the beginning of the TIFF file. Note that this
// implies that each strip has a location independent of the locations of other strips.
// This feature may be useful for editing applications. This required field is the only
// way for a reader to find the image data. (Unless TileOffsets is used; see
// TileOffsets.)
// Note that either SHORT or LONG values may be used to specify the strip offsets.
// SHORT values may be used for small TIFF files. It should be noted, however, that
// earlier TIFF specifications required LONG strip offsets and that some software
// may not accept SHORT values.
// For maximum compatibility with operating systems such as MS-DOS and Win-
// dows, the StripOffsets array should be less than or equal to 64K bytes in length,
// and the strips themselves, in both compressed and uncompressed forms, should
// not be larger than 64K bytes.
// No default. See also StripByteCounts, RowsPerStrip, TileOffsets,
// TileByteCounts.
},{
"SubfileType",
// A general indication of the kind of data contained in this subfile.
TIFFTAG_OSUBFILETYPE,
TIFF_SHORT
// N = 1
// Currently defined values are:
// 1 = full-resolution image data
// 2 = reduced-resolution image data
// 3 = a single page of a multi-page image (see the PageNumber field description).
// Note that several image types may be found in a single TIFF file, with each subfile
// described by its own IFD.
// No default.
// This field is deprecated. The NewSubfileType field should be used instead.
},{
"Threshholding",
// For black and white TIFF files that represent shades of gray, the technique used to
// convert from gray to black and white pixels.
TIFFTAG_THRESHHOLDING,
TIFF_SHORT
// N = 1
// 1 = No dithering or halftoning has been applied to the image data.
// 2 = An ordered dither or halftone technique has been applied to the image data.
// 3 = A randomized process such as error diffusion has been applied to the image data.
// Default is Threshholding = 1. See also CellWidth, CellLength.
},{
"XResolution",
// The number of pixels per ResolutionUnit in the ImageWidth direction.
TIFFTAG_XRESOLUTION,
TIFF_RATIONAL
// N = 1
// It is not mandatory that the image be actually displayed or printed at the size implied
// by this parameter. It is up to the application to use this information as it wishes.
// No default. See also YResolution, ResolutionUnit.
},{
"YResolution",
// The number of pixels per ResolutionUnit in the ImageLength direction.
TIFFTAG_YRESOLUTION ,
TIFF_RATIONAL
// N = 1
// No default. See also XResolution, ResolutionUnit.
//
},
//// SUPPLEMENT 1 TAGS
{
"SubIFDs",
TIFFTAG_SUBIFD,
TIFF_IFD // or “LONG”. “IFD” is preferred.
// Note: When writing, TIFF_IFD tags are always saved as LONG for compatibility with dcraw and dcraw-derived applications.
// N = number of child IFDs
// Each value is an offset (from the beginning of the TIFF file, as always) to a child
// IFD. Child images provide extra information for the parent image—such as a
// subsampled version of the parent image.
// TIFF data type 13, “IFD,” is otherwise identical to LONG, but is only used to
// point to other valid IFDs.
},
//// TIFF Extension tags
{
"TileWidth",
TIFFTAG_TILEWIDTH,
TIFF_SHORT // or LONG
// N = 1
// The tile width in pixels. This is the number of columns in each tile.
// Assuming integer arithmetic, three computed values that are useful in the follow-
// ing field descriptions are:
// TilesAcross = (ImageWidth + TileWidth - 1) / TileWidth
// TilesDown = (ImageLength + TileLength - 1) / TileLength
// TilesPerImage = TilesAcross * TilesDown
// These computed values are not TIFF fields; they are simply values determined by
// the ImageWidth, TileWidth, ImageLength, and TileLength fields.
// TileWidth and ImageWidth together determine the number of tiles that span the
// width of the image (TilesAcross). TileLength and ImageLength together deter-
// mine the number of tiles that span the length of the image (TilesDown).
// We recommend choosing TileWidth and TileLength such that the resulting tiles
// are about 4K to 32K bytes before compression. This seems to be a reasonable
// value for most applications and compression schemes.
// TileWidth must be a multiple of 16. This restriction improves performance in
// some graphics environments and enhances compatibility with compression
// schemes such as JPEG.
// Tiles need not be square.
// Note that ImageWidth can be less than TileWidth, although this means that the
// tiles are too large or that you are using tiling on really small images, neither of
// which is recommended. The same observation holds for ImageLength and
// TileLength.
// No default. See also TileLength, TileOffsets, TileByteCounts.
},{
"TileLength",
TIFFTAG_TILELENGTH,
TIFF_SHORT // or LONG
// N = 1
// The tile length (height) in pixels. This is the number of rows in each tile.
// TileLength must be a multiple of 16 for compatibility with compression schemes
// such as JPEG.
// Replaces RowsPerStrip in tiled TIFF files.
// No default. See also TileWidth, TileOffsets, TileByteCounts.
},{
"TileOffsets",
TIFFTAG_TILEOFFSETS,
TIFF_LONG
// N = TilesPerImage for PlanarConfiguration = 1
// = SamplesPerPixel * TilesPerImage for PlanarConfiguration = 2
// For each tile, the byte offset of that tile, as compressed and stored on disk. The
// offset is specified with respect to the beginning of the TIFF file. Note that this
// implies that each tile has a location independent of the locations of other tiles.
// Offsets are ordered left-to-right and top-to-bottom. For PlanarConfiguration = 2,
// the offsets for the first component plane are stored first, followed by all the offsets
// for the second component plane, and so on.
// No default. See also TileWidth, TileLength, TileByteCounts.
},{
"TileByteCounts",
TIFFTAG_TILEBYTECOUNTS,
TIFF_SHORT // or LONG
// N = TilesPerImage for PlanarConfiguration = 1
// = SamplesPerPixel * TilesPerImage for PlanarConfiguration = 2
// For each tile, the number of (compressed) bytes in that tile.
// See TileOffsets for a description of how the byte counts are ordered.
// No default. See also TileWidth, TileLength, TileOffsets.
},
// TIFF/EP Tags (knowledge inferred from many places, ISO spec costs money)
{
"TIFF/EPStandardID",
37398,
TIFF_BYTE,
// Note: Below inferred from various sources
// Count:
// 4
// Value:
// See below
// Default:
// Required tag
// Usage:
// IFD 0
// Description:
// Should always be 1 0 0 0
},
{
"CFAPattern",
TIFFTAG_CFAPATTERN,
TIFF_BYTE
// Count Number of pixels in a single CFA pattern repetition
// Default None
// Description
// Indicates the color filter array (CFA) geometric pattern of the image sensor when a one-chip color area sensor is used.
// It does not apply to all sensing methods.
// The value consists of an id code for every pixel in that pattern. The pattern shape is given by CFARepeatPatternDim, the pixels
// are listed left-to-right, top-to-bottom, with the first pattern starting at the top-left corner of the sensor.
// This identification code can be:
// 0 = Red
// 1 = Green
// 2 = Blue
// 3 = Cyan
// 4 = Magenta
// 5 = Yellow
// 6 = White
}, {
"CFARepeatPatternDim",
TIFFTAG_CFAREPEATPATTERNDIM,
TIFF_SHORT
// Count 2
// Default ?
// Description
// (inferred from Boris's saving code, web info - Eddy)
// Dimensions of the CFA repeating pattern, as two shorts. The colors that make up the pattern are given by CFAPattern
},
//// DNG TAGS
{
"DNGVersion",
TIFFTAG_DNGVERSION,
TIFF_BYTE,
// Count:
// 4
// Value:
// See below
// Default:
// Required tag
// Usage:
// IFD 0
// Description:
// This tag encodes the DNG four-tier version number. For
// files compliant with this version of the DNG specification
// (1.2.0.0), this tag should contain the bytes: 1, 2, 0, 0.
},{
"DNGBackwardVersion",
TIFFTAG_DNGBACKWARDVERSION,
TIFF_BYTE,
// Count:
// 4
// Value:
// See below
// Default:
// DNGVersion with the last two bytes set to zero.
// Usage:
// IFD 0
// Description:
// This tag specifies the oldest version of the Digital
// Negative specification for which a file is
// compatible. Readers should not attempt to read a file if
// this tag specifies a version number that is higher than the
// version number of the specification the reader was based
// on. In addition to checking the version tags, readers
// should, for all tags, check the types, counts, and values,
// to verify it is able to correctly read the file. For more
// information on compatibility with previous DNG versions,
// see Appendix A: Compatibility with Previous Versions.
},{
"UniqueCameraModel",
TIFFTAG_UNIQUECAMERAMODEL,
TIFF_ASCII,
// Count:
// String length including null
// Value:
// Null terminated string
// Default:
// Required tag
// Usage:
// IFD 0
// Description:
// UniqueCameraModel defines a unique, non-localized name for
// the camera model that created the image in the raw
// file. This name should include the manufacturer's name to
// avoid conflicts, and should not be localized, even if the
// camera name itself is localized for different markets (see
// LocalizedCameraModel).
// This string may be used by reader software to index into
// per-model preferences and replacement profiles. Examples
// of unique model names are:
// •"Canon EOS 300D"
// •"Fujifilm FinePix S2Pro"
// •"Kodak ProBack645"
// •"Minolta DiMAGE A1"
// •"Nikon D1X"
// •"Olympus C-5050Z"
// •"Pentax *istD"
// •"Sony F828"
},{
"LocalizedCameraModel",
TIFFTAG_LOCALIZEDCAMERAMODEL,
TIFF_ASCII //or BYTE,
// Count:
// Byte count including null
// Value:
// Null terminated UTF-8 encoded Unicode string
// Default:
// Same as UniqueCameraModel
// Usage:
// IFD 0
// Description:
// Similar to the UniqueCameraModel field, except the name can
// be localized for different markets to match the
// localization of the camera name.
},{
"CFAPlaneColor",
TIFFTAG_CFAPLANECOLOR,
TIFF_BYTE,
// Count:
// ColorPlanes
// Value:
// See below
// Default:
// 0, 1, 2 (red, green, blue)
// Usage:
// Raw IFD
// Description:
// CFAPlaneColor provides a mapping between the values in the
// CFAPattern tag and the plane numbers in LinearRaw
// space. This is a required tag for non-RGB CFA images
},{
"CFALayout",
TIFFTAG_CFALAYOUT,
TIFF_SHORT,
// Count:
// 1
// Value:
// See below
// Default:
// 1
// Usage:
// Raw IFD
// Description:
// CFALayout describes the spatial layout of the CFA. The currently defined values are:
// 1 = Rectangular (or square) layout
// 2 = Staggered layout A: even columns are offset down by 1/2 row
// 3 = Staggered layout B: even columns are offset up by 1/2 row
// 4 = Staggered layout C: even rows are offset right by 1/2 column
// 5 = Staggered layout D: even rows are offset left by 1/2 column
// 6 = Staggered layout E: even rows are offset up by 1/2 row, even columns are offset left by 1/2 column
// 7 = Staggered layout F: even rows are offset up by 1/2 row, even columns are offset right by 1/2 column
// 8 = Staggered layout G: even rows are offset down by 1/2 row, even columns are offset left by 1/2 column
// 9 = Staggered layout H: even rows are offset down by 1/2 row, even columns are offset right by 1/2 column
// Note that for the purposes of this tag, rows and columns are numbered starting with one.
// Layout values 6 through 9 were added with DNG version 1.3.0.0.
},{
"LinearizationTable",
TIFFTAG_LINEARIZATIONTABLE,
TIFF_SHORT,
// Count:
// N
// Value:
// See below
// Default:
// Identity table (0, 1, 2, 3, etc.)
// Usage:
// Raw IFD
// Description:
// LinearizationTable describes a lookup table that maps
// stored values into linear values. This tag is typically
// used to increase compression ratios by storing the raw data
// in a non-linear, more visually uniform space with fewer
// total encoding levels. If SamplesPerPixel is not equal to
// one, this single table applies to all the samples for each
// pixel. See Chapter 5, “Mapping Raw Values to Linear
// Reference Values” on page 65 for details of the processing
// model.
},{
"BlackLevelRepeatDim",
TIFFTAG_BLACKLEVELREPEATDIM,
TIFF_SHORT,
// Count:
// 2
// Value:
// Value: 0: BlackLevelRepeatRows
// Value: 1: BlackLevelRepeatCols
// Default:
// 1, 1
// Usage:
// Raw IFD
// Description:
// This tag specifies repeat pattern size for the BlackLevel tag.
},{
"BlackLevel",
TIFFTAG_BLACKLEVEL,
TIFF_SHORT // or LONG or RATIONAL,
// Count:
// BlackLevelRepeatRows * BlackLevelRepeatCols * SamplesPerPixel
// Value:
// See below
// Default:
// 0
// Usage:
// Raw IFD
// Description:
// This tag specifies the zero light (a.k.a. thermal black or
// black current) encoding level, as a repeating pattern. The
// origin of this pattern is the top-left corner of the
// ActiveArea rectangle. The values are stored in
// row-column-sample scan order. See Chapter 5, “Mapping Raw
// Values to Linear Reference Values” on page 65 for details
// of the processing model.
},{
"BlackLevelDeltaH",
TIFFTAG_BLACKLEVELDELTAH,
TIFF_SRATIONAL,
// Count:
// ActiveArea width
// Value:
// See below
// Default:
// All zeros
// Usage:
// Raw IFD
// Description:
// If the zero light encoding level is a function of the image
// column, BlackLevelDeltaH specifies the difference between
// the zero light encoding level for each column and the
// baseline zero light encoding level. If SamplesPerPixel is
// not equal to one, this single table applies to all the
// samples for each pixel. See Chapter 5, “Mapping Raw Values
// to Linear Reference Values” on page 65 for details of the
// processing model.
},{
"BlackLevelDeltaV",
TIFFTAG_BLACKLEVELDELTAV,
TIFF_SRATIONAL,
// Count:
// ActiveArea length
// Value:
// See below
// Default:
// All zeros
// Usage:
// Raw IFD
// Description:
// If the zero light encoding level is a function of the image
// row, this tag specifies the difference between the zero
// light encoding level for each row and the baseline zero
// light encoding level. If SamplesPerPixel is not equal to
// one, this single table applies to all the samples for each
// pixel. See Chapter 5, “Mapping Raw Values to Linear
// Reference Values” on page 65 for details of the processing
// model.
},{
"WhiteLevel",
TIFFTAG_WHITELEVEL,
TIFF_SHORT //or LONG,
// Count:
// SamplesPerPixel
// Value:
// See below
// Default:
// (2 ** BitsPerSample) - 1
// Usage:
// Raw IFD
// Description:
// This tag specifies the fully saturated encoding level for
// the raw sample values. Saturation is caused either by the