Completed
Push — vendor/getid3 ( 69b815...49c253 )
by Pauli
04:26 queued 01:37
created

getid3_tiff   F

Complexity

Total Complexity 62

Size/Duplication

Total Lines 496
Duplicated Lines 6.05 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 30
loc 496
rs 3.44
c 0
b 0
f 0
wmc 62
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
F Analyze() 30 188 53
A TIFFendian2Int() 0 8 3
A TIFFcompressionMethod() 0 32 3
B TIFFcommentName() 0 241 3

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like getid3_tiff often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use getid3_tiff, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/////////////////////////////////////////////////////////////////
4
/// getID3() by James Heinrich <[email protected]>               //
5
//  available at https://github.com/JamesHeinrich/getID3       //
6
//            or https://www.getid3.org                        //
7
//            or http://getid3.sourceforge.net                 //
8
//  see readme.txt for more details                            //
9
/////////////////////////////////////////////////////////////////
10
//                                                             //
11
// module.archive.tiff.php                                     //
12
// module for analyzing TIFF files                             //
13
// dependencies: NONE                                          //
14
//                                                            ///
15
/////////////////////////////////////////////////////////////////
16
17
18
class getid3_tiff extends getid3_handler
19
{
20
	/**
21
	 * @return bool
22
	 */
23
	public function Analyze() {
24
		$info = &$this->getid3->info;
25
26
		$this->fseek($info['avdataoffset']);
27
		$TIFFheader = $this->fread(4);
28
29
		switch (substr($TIFFheader, 0, 2)) {
30
			case 'II':
31
				$info['tiff']['byte_order'] = 'Intel';
32
				break;
33
			case 'MM':
34
				$info['tiff']['byte_order'] = 'Motorola';
35
				break;
36
			default:
37
				$this->error('Invalid TIFF byte order identifier ('.substr($TIFFheader, 0, 2).') at offset '.$info['avdataoffset']);
38
				return false;
39
		}
40
41
		$info['fileformat']          = 'tiff';
42
		$info['video']['dataformat'] = 'tiff';
43
		$info['video']['lossless']   = true;
44
		$info['tiff']['ifd']         = array();
45
		$CurrentIFD                  = array();
46
47
		$FieldTypeByteLength = array(1=>1, 2=>1, 3=>2, 4=>4, 5=>8);
48
49
		$nextIFDoffset = $this->TIFFendian2Int($this->fread(4), $info['tiff']['byte_order']);
0 ignored issues
show
Security Bug introduced by
It seems like $this->fread(4) targeting getid3_handler::fread() can also be of type false; however, getid3_tiff::TIFFendian2Int() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
50
51
		while ($nextIFDoffset > 0) {
52
53
			$CurrentIFD['offset'] = $nextIFDoffset;
54
55
			$this->fseek($info['avdataoffset'] + $nextIFDoffset);
56
			$CurrentIFD['fieldcount'] = $this->TIFFendian2Int($this->fread(2), $info['tiff']['byte_order']);
0 ignored issues
show
Security Bug introduced by
It seems like $this->fread(2) targeting getid3_handler::fread() can also be of type false; however, getid3_tiff::TIFFendian2Int() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
57
58
			for ($i = 0; $i < $CurrentIFD['fieldcount']; $i++) {
59
				$CurrentIFD['fields'][$i]['raw']['tag']      = $this->TIFFendian2Int($this->fread(2), $info['tiff']['byte_order']);
0 ignored issues
show
Security Bug introduced by
It seems like $this->fread(2) targeting getid3_handler::fread() can also be of type false; however, getid3_tiff::TIFFendian2Int() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
60
				$CurrentIFD['fields'][$i]['raw']['type']     = $this->TIFFendian2Int($this->fread(2), $info['tiff']['byte_order']);
0 ignored issues
show
Security Bug introduced by
It seems like $this->fread(2) targeting getid3_handler::fread() can also be of type false; however, getid3_tiff::TIFFendian2Int() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
61
				$CurrentIFD['fields'][$i]['raw']['length']   = $this->TIFFendian2Int($this->fread(4), $info['tiff']['byte_order']);
0 ignored issues
show
Security Bug introduced by
It seems like $this->fread(4) targeting getid3_handler::fread() can also be of type false; however, getid3_tiff::TIFFendian2Int() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
62
				$CurrentIFD['fields'][$i]['raw']['valoff']   =                       $this->fread(4); // To save time and space the Value Offset contains the Value instead of pointing to the Value if and only if the Value fits into 4 bytes. If the Value is shorter than 4 bytes, it is left-justified within the 4-byte Value Offset, i.e., stored in the lowernumbered bytes. Whether the Value fits within 4 bytes is determined by the Type and Count of the field.
63
				$CurrentIFD['fields'][$i]['raw']['tag_name'] = $this->TIFFcommentName($CurrentIFD['fields'][$i]['raw']['tag']);
64
65
				switch ($CurrentIFD['fields'][$i]['raw']['type']) {
66 View Code Duplication
					case 1: // BYTE  An 8-bit unsigned integer.
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 4) {
68
							$CurrentIFD['fields'][$i]['value']  = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['valoff'], 0, 1), $info['tiff']['byte_order']);
69
						} else {
70
							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['valoff'], $info['tiff']['byte_order']);
71
						}
72
						break;
73
74
					case 2: // ASCII 8-bit bytes  that store ASCII codes; the last byte must be null.
75
						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 4) {
76
							$CurrentIFD['fields'][$i]['value']  = substr($CurrentIFD['fields'][$i]['raw']['valoff'], 3);
77
						} else {
78
							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['valoff'], $info['tiff']['byte_order']);
79
						}
80
						break;
81
82 View Code Duplication
					case 3: // SHORT A 16-bit (2-byte) unsigned integer.
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 2) {
84
							$CurrentIFD['fields'][$i]['value']  = $this->TIFFendian2Int(substr($CurrentIFD['fields'][$i]['raw']['valoff'], 0, 2), $info['tiff']['byte_order']);
85
						} else {
86
							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['valoff'], $info['tiff']['byte_order']);
87
						}
88
						break;
89
90 View Code Duplication
					case 4: // LONG  A 32-bit (4-byte) unsigned integer.
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
						if ($CurrentIFD['fields'][$i]['raw']['length'] <= 4) {
92
							$CurrentIFD['fields'][$i]['value']  = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['valoff'], $info['tiff']['byte_order']);
93
						} else {
94
							$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['valoff'], $info['tiff']['byte_order']);
95
						}
96
						break;
97
98
					case 5: // RATIONAL   Two LONG_s:  the first represents the numerator of a fraction, the second the denominator.
99
					case 7: // UNDEFINED An 8-bit byte that may contain anything, depending on the definition of the field.
100
						$CurrentIFD['fields'][$i]['offset'] = $this->TIFFendian2Int($CurrentIFD['fields'][$i]['raw']['valoff'], $info['tiff']['byte_order']);
101
						break;
102
103
					// Warning: It is possible that other TIFF field types will be added in the future. Readers should skip over fields containing an unexpected field type.
104
					// In TIFF 6.0, some new field types have been defined:
105
					// These new field types are also governed by the byte order (II or MM) in the TIFF header.
106
					case 6: // SBYTE An 8-bit signed (twos-complement) integer.
107
					case 8: // SSHORT A 16-bit (2-byte) signed (twos-complement) integer.
108
					case 9: // SLONG A 32-bit (4-byte) signed (twos-complement) integer.
109
					case 10: // SRATIONAL Two SLONGs: the first represents the numerator of a fraction, the second the denominator.
110
					case 11: // FLOAT Single precision (4-byte) IEEE format
111
					case 12: // DOUBLE Double precision (8-byte) IEEE format
112
					default:
113
						$this->warning('unhandled IFD field type '.$CurrentIFD['fields'][$i]['raw']['type'].' for IFD entry '.$i);
114
						break;
115
				}
116
			}
117
118
			$info['tiff']['ifd'][] = $CurrentIFD;
119
			$CurrentIFD = array();
120
			$nextIFDoffset = $this->TIFFendian2Int($this->fread(4), $info['tiff']['byte_order']);
0 ignored issues
show
Security Bug introduced by
It seems like $this->fread(4) targeting getid3_handler::fread() can also be of type false; however, getid3_tiff::TIFFendian2Int() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
121
122
		}
123
124
		foreach ($info['tiff']['ifd'] as $IFDid => $IFDarray) {
125
			foreach ($IFDarray['fields'] as $key => $fieldarray) {
126
				switch ($fieldarray['raw']['tag']) {
127
					case 256: // ImageWidth
128
					case 257: // ImageLength
129
					case 258: // BitsPerSample
130
					case 259: // Compression
131
						if (!isset($fieldarray['value'])) {
132
							$this->fseek($fieldarray['offset']);
133
							$info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = $this->fread($fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
134
135
						}
136
						break;
137
138
					case 270: // ImageDescription
139
					case 271: // Make
140
					case 272: // Model
141
					case 305: // Software
142
					case 306: // DateTime
143
					case 315: // Artist
144 View Code Duplication
					case 316: // HostComputer
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
145
						if (isset($fieldarray['value'])) {
146
							$info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = $fieldarray['value'];
147
						} else {
148
							$this->fseek($fieldarray['offset']);
149
							$info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'] = $this->fread($fieldarray['raw']['length'] * $FieldTypeByteLength[$fieldarray['raw']['type']]);
150
151
						}
152
						break;
153
					case 700:
154
						$XMPmagic = '<?xpacket';
155
						$this->fseek($fieldarray['offset']);
156
						$xmpkey = (isset($info['tiff']['XMP']) ? count($info['tiff']['XMP']) : 0);
157
						$info['tiff']['XMP'][$xmpkey]['raw'] = $this->fread($fieldarray['raw']['length']);
158
						if (substr($info['tiff']['XMP'][$xmpkey]['raw'], 0, strlen($XMPmagic)) != $XMPmagic) {
159
							$this->warning('did not find expected XMP data at offset '.$fieldarray['offset']);
160
							unset($info['tiff']['XMP'][$xmpkey]['raw']);
161
						}
162
						break;
163
				}
164
				switch ($fieldarray['raw']['tag']) {
165
					case 256: // ImageWidth
166
						$info['video']['resolution_x'] = $fieldarray['value'];
167
						break;
168
169
					case 257: // ImageLength
170
						$info['video']['resolution_y'] = $fieldarray['value'];
171
						break;
172
173
					case 258: // BitsPerSample
174
						if (isset($fieldarray['value'])) {
175
							$info['video']['bits_per_sample'] = $fieldarray['value'];
176
						} else {
177
							$info['video']['bits_per_sample'] = 0;
178
							for ($i = 0; $i < $fieldarray['raw']['length']; $i++) {
179
								$info['video']['bits_per_sample'] += $this->TIFFendian2Int(substr($info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'], $i * $FieldTypeByteLength[$fieldarray['raw']['type']], $FieldTypeByteLength[$fieldarray['raw']['type']]), $info['tiff']['byte_order']);
180
							}
181
						}
182
						break;
183
184
					case 259: // Compression
185
						$info['video']['codec'] = $this->TIFFcompressionMethod($fieldarray['value']);
186
						break;
187
188
					case 270: // ImageDescription
189
					case 271: // Make
190
					case 272: // Model
191
					case 305: // Software
192
					case 306: // DateTime
193
					case 315: // Artist
194
					case 316: // HostComputer
195
						$TIFFcommentName = strtolower($fieldarray['raw']['tag_name']);
196
						if (isset($info['tiff']['comments'][$TIFFcommentName])) {
197
							$info['tiff']['comments'][$TIFFcommentName][] =       $info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data'];
198
						} else {
199
							$info['tiff']['comments'][$TIFFcommentName]   = array($info['tiff']['ifd'][$IFDid]['fields'][$key]['raw']['data']);
200
						}
201
						break;
202
203
					default:
204
						break;
205
				}
206
			}
207
		}
208
209
		return true;
210
	}
211
212
	/**
213
	 * @param string $bytestring
214
	 * @param string $byteorder
215
	 *
216
	 * @return int|float|false
217
	 */
218
	public function TIFFendian2Int($bytestring, $byteorder) {
219
		if ($byteorder == 'Intel') {
220
			return getid3_lib::LittleEndian2Int($bytestring);
221
		} elseif ($byteorder == 'Motorola') {
222
			return getid3_lib::BigEndian2Int($bytestring);
223
		}
224
		return false;
225
	}
226
227
	/**
228
	 * @param int $id
229
	 *
230
	 * @return string
231
	 */
232
	public function TIFFcompressionMethod($id) {
233
		// https://en.wikipedia.org/wiki/TIFF#TIFF_Compression_Tag
234
		static $TIFFcompressionMethod = array();
235
		if (empty($TIFFcompressionMethod)) {
236
			$TIFFcompressionMethod = array(
237
				0x0001 => 'Uncompressed',
238
				0x0002 => 'Huffman',
239
				0x0003 => 'CCITT T.4',
240
				0x0004 => 'CCITT T.6',
241
				0x0005 => 'LZW',
242
				0x0006 => 'JPEG-old',
243
				0x0007 => 'JPEG',
244
				0x0008 => 'deflate',
245
				0x0009 => 'JBIG ITU-T T.85',
246
				0x000A => 'JBIG ITU-T T.43',
247
				0x7FFE => 'NeXT RLE 2-bit',
248
				0x8005 => 'PackBits',
249
				0x8029 => 'ThunderScan RLE 4-bit',
250
				0x807F => 'RasterPadding',
251
				0x8080 => 'RLE-LW',
252
				0x8081 => 'RLE-CT',
253
				0x8082 => 'RLE-BL',
254
				0x80B2 => 'deflate-PK',
255
				0x80B3 => 'Kodak-DCS',
256
				0x8765 => 'JBIG',
257
				0x8798 => 'JPEG2000',
258
				0x8799 => 'Nikon NEF',
259
				0x879B => 'JBIG2',
260
			);
261
		}
262
		return (isset($TIFFcompressionMethod[$id]) ? $TIFFcompressionMethod[$id] : 'unknown/invalid ('.$id.')');
263
	}
264
265
	/**
266
	 * @param int $id
267
	 *
268
	 * @return string
269
	 */
270
	public function TIFFcommentName($id) {
271
		// https://www.awaresystems.be/imaging/tiff/tifftags.html
272
		static $TIFFcommentName = array();
273
		if (empty($TIFFcommentName)) {
274
			$TIFFcommentName = array(
275
				254 => 'NewSubfileType',
276
				255 => 'SubfileType',
277
				256 => 'ImageWidth',
278
				257 => 'ImageLength',
279
				258 => 'BitsPerSample',
280
				259 => 'Compression',
281
				262 => 'PhotometricInterpretation',
282
				263 => 'Threshholding',
283
				264 => 'CellWidth',
284
				265 => 'CellLength',
285
				266 => 'FillOrder',
286
				269 => 'DocumentName',
287
				270 => 'ImageDescription',
288
				271 => 'Make',
289
				272 => 'Model',
290
				273 => 'StripOffsets',
291
				274 => 'Orientation',
292
				277 => 'SamplesPerPixel',
293
				278 => 'RowsPerStrip',
294
				279 => 'StripByteCounts',
295
				280 => 'MinSampleValue',
296
				281 => 'MaxSampleValue',
297
				282 => 'XResolution',
298
				283 => 'YResolution',
299
				284 => 'PlanarConfiguration',
300
				285 => 'PageName',
301
				286 => 'XPosition',
302
				287 => 'YPosition',
303
				288 => 'FreeOffsets',
304
				289 => 'FreeByteCounts',
305
				290 => 'GrayResponseUnit',
306
				291 => 'GrayResponseCurve',
307
				292 => 'T4Options',
308
				293 => 'T6Options',
309
				296 => 'ResolutionUnit',
310
				297 => 'PageNumber',
311
				301 => 'TransferFunction',
312
				305 => 'Software',
313
				306 => 'DateTime',
314
				315 => 'Artist',
315
				316 => 'HostComputer',
316
				317 => 'Predictor',
317
				318 => 'WhitePoint',
318
				319 => 'PrimaryChromaticities',
319
				320 => 'ColorMap',
320
				321 => 'HalftoneHints',
321
				322 => 'TileWidth',
322
				323 => 'TileLength',
323
				324 => 'TileOffsets',
324
				325 => 'TileByteCounts',
325
				326 => 'BadFaxLines',
326
				327 => 'CleanFaxData',
327
				328 => 'ConsecutiveBadFaxLines',
328
				330 => 'SubIFDs',
329
				332 => 'InkSet',
330
				333 => 'InkNames',
331
				334 => 'NumberOfInks',
332
				336 => 'DotRange',
333
				337 => 'TargetPrinter',
334
				338 => 'ExtraSamples',
335
				339 => 'SampleFormat',
336
				340 => 'SMinSampleValue',
337
				341 => 'SMaxSampleValue',
338
				342 => 'TransferRange',
339
				343 => 'ClipPath',
340
				344 => 'XClipPathUnits',
341
				345 => 'YClipPathUnits',
342
				346 => 'Indexed',
343
				347 => 'JPEGTables',
344
				351 => 'OPIProxy',
345
				400 => 'GlobalParametersIFD',
346
				401 => 'ProfileType',
347
				402 => 'FaxProfile',
348
				403 => 'CodingMethods',
349
				404 => 'VersionYear',
350
				405 => 'ModeNumber',
351
				433 => 'Decode',
352
				434 => 'DefaultImageColor',
353
				512 => 'JPEGProc',
354
				513 => 'JPEGInterchangeFormat',
355
				514 => 'JPEGInterchangeFormatLngth',
356
				515 => 'JPEGRestartInterval',
357
				517 => 'JPEGLosslessPredictors',
358
				518 => 'JPEGPointTransforms',
359
				519 => 'JPEGQTables',
360
				520 => 'JPEGDCTables',
361
				521 => 'JPEGACTables',
362
				529 => 'YCbCrCoefficients',
363
				530 => 'YCbCrSubSampling',
364
				531 => 'YCbCrPositioning',
365
				532 => 'ReferenceBlackWhite',
366
				559 => 'StripRowCounts',
367
				700 => 'XMP',
368
369
				32781 => 'ImageID',
370
				33432 => 'Copyright',
371
				34732 => 'ImageLayer',
372
373
				// Private Tags - https://www.awaresystems.be/imaging/tiff/tifftags/private.html
374
				32932 => 'Wang Annotation',                    // Annotation data, as used in 'Imaging for Windows'.
375
				33445 => 'MD FileTag',                         // Specifies the pixel data format encoding in the Molecular Dynamics GEL file format.
376
				33446 => 'MD ScalePixel',                      // Specifies a scale factor in the Molecular Dynamics GEL file format.
377
				33447 => 'MD ColorTable',                      // Used to specify the conversion from 16bit to 8bit in the Molecular Dynamics GEL file format.
378
				33448 => 'MD LabName',                         // Name of the lab that scanned this file, as used in the Molecular Dynamics GEL file format.
379
				33449 => 'MD SampleInfo',                      // Information about the sample, as used in the Molecular Dynamics GEL file format.
380
				33450 => 'MD PrepDate',                        // Date the sample was prepared, as used in the Molecular Dynamics GEL file format.
381
				33451 => 'MD PrepTime',                        // Time the sample was prepared, as used in the Molecular Dynamics GEL file format.
382
				33452 => 'MD FileUnits',                       // Units for data in this file, as used in the Molecular Dynamics GEL file format.
383
				33550 => 'ModelPixelScaleTag',                 // Used in interchangeable GeoTIFF files.
384
				33723 => 'IPTC',                               // IPTC (International Press Telecommunications Council) metadata.
385
				33918 => 'INGR Packet Data Tag',               // Intergraph Application specific storage.
386
				33919 => 'INGR Flag Registers',                // Intergraph Application specific flags.
387
				33920 => 'IrasB Transformation Matrix',        // Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only.
388
				33922 => 'ModelTiepointTag',                   // Originally part of Intergraph's GeoTIFF tags, but now used in interchangeable GeoTIFF files.
389
				34264 => 'ModelTransformationTag',             // Used in interchangeable GeoTIFF files.
390
				34377 => 'Photoshop',                          // Collection of Photoshop 'Image Resource Blocks'.
391
				34665 => 'Exif IFD',                           // A pointer to the Exif IFD.
392
				34675 => 'ICC Profile',                        // ICC profile data.
393
				34735 => 'GeoKeyDirectoryTag',                 // Used in interchangeable GeoTIFF files.
394
				34736 => 'GeoDoubleParamsTag',                 // Used in interchangeable GeoTIFF files.
395
				34737 => 'GeoAsciiParamsTag',                  // Used in interchangeable GeoTIFF files.
396
				34853 => 'GPS IFD',                            // A pointer to the Exif-related GPS Info IFD.
397
				34908 => 'HylaFAX FaxRecvParams',              // Used by HylaFAX.
398
				34909 => 'HylaFAX FaxSubAddress',              // Used by HylaFAX.
399
				34910 => 'HylaFAX FaxRecvTime',                // Used by HylaFAX.
400
				37724 => 'ImageSourceData',                    // Used by Adobe Photoshop.
401
				40965 => 'Interoperability IFD',               // A pointer to the Exif-related Interoperability IFD.
402
				42112 => 'GDAL_METADATA',                      // Used by the GDAL library, holds an XML list of name=value 'metadata' values about the image as a whole, and about specific samples.
403
				42113 => 'GDAL_NODATA',                        // Used by the GDAL library, contains an ASCII encoded nodata or background pixel value.
404
				50215 => 'Oce Scanjob Description',            // Used in the Oce scanning process.
405
				50216 => 'Oce Application Selector',           // Used in the Oce scanning process.
406
				50217 => 'Oce Identification Number',          // Used in the Oce scanning process.
407
				50218 => 'Oce ImageLogic Characteristics',     // Used in the Oce scanning process.
408
				50706 => 'DNGVersion',                         // Used in IFD 0 of DNG files.
409
				50707 => 'DNGBackwardVersion',                 // Used in IFD 0 of DNG files.
410
				50708 => 'UniqueCameraModel',                  // Used in IFD 0 of DNG files.
411
				50709 => 'LocalizedCameraModel',               // Used in IFD 0 of DNG files.
412
				50710 => 'CFAPlaneColor',                      // Used in Raw IFD of DNG files.
413
				50711 => 'CFALayout',                          // Used in Raw IFD of DNG files.
414
				50712 => 'LinearizationTable',                 // Used in Raw IFD of DNG files.
415
				50713 => 'BlackLevelRepeatDim',                // Used in Raw IFD of DNG files.
416
				50714 => 'BlackLevel',                         // Used in Raw IFD of DNG files.
417
				50715 => 'BlackLevelDeltaH',                   // Used in Raw IFD of DNG files.
418
				50716 => 'BlackLevelDeltaV',                   // Used in Raw IFD of DNG files.
419
				50717 => 'WhiteLevel',                         // Used in Raw IFD of DNG files.
420
				50718 => 'DefaultScale',                       // Used in Raw IFD of DNG files.
421
				50719 => 'DefaultCropOrigin',                  // Used in Raw IFD of DNG files.
422
				50720 => 'DefaultCropSize',                    // Used in Raw IFD of DNG files.
423
				50721 => 'ColorMatrix1',                       // Used in IFD 0 of DNG files.
424
				50722 => 'ColorMatrix2',                       // Used in IFD 0 of DNG files.
425
				50723 => 'CameraCalibration1',                 // Used in IFD 0 of DNG files.
426
				50724 => 'CameraCalibration2',                 // Used in IFD 0 of DNG files.
427
				50725 => 'ReductionMatrix1',                   // Used in IFD 0 of DNG files.
428
				50726 => 'ReductionMatrix2',                   // Used in IFD 0 of DNG files.
429
				50727 => 'AnalogBalance',                      // Used in IFD 0 of DNG files.
430
				50728 => 'AsShotNeutral',                      // Used in IFD 0 of DNG files.
431
				50729 => 'AsShotWhiteXY',                      // Used in IFD 0 of DNG files.
432
				50730 => 'BaselineExposure',                   // Used in IFD 0 of DNG files.
433
				50731 => 'BaselineNoise',                      // Used in IFD 0 of DNG files.
434
				50732 => 'BaselineSharpness',                  // Used in IFD 0 of DNG files.
435
				50733 => 'BayerGreenSplit',                    // Used in Raw IFD of DNG files.
436
				50734 => 'LinearResponseLimit',                // Used in IFD 0 of DNG files.
437
				50735 => 'CameraSerialNumber',                 // Used in IFD 0 of DNG files.
438
				50736 => 'LensInfo',                           // Used in IFD 0 of DNG files.
439
				50737 => 'ChromaBlurRadius',                   // Used in Raw IFD of DNG files.
440
				50738 => 'AntiAliasStrength',                  // Used in Raw IFD of DNG files.
441
				50740 => 'DNGPrivateData',                     // Used in IFD 0 of DNG files.
442
				50741 => 'MakerNoteSafety',                    // Used in IFD 0 of DNG files.
443
				50778 => 'CalibrationIlluminant1',             // Used in IFD 0 of DNG files.
444
				50779 => 'CalibrationIlluminant2',             // Used in IFD 0 of DNG files.
445
				50780 => 'BestQualityScale',                   // Used in Raw IFD of DNG files.
446
				50784 => 'Alias Layer Metadata',               // Alias Sketchbook Pro layer usage description.
447
				50908 => 'TIFF_RSID',                          // This private tag is used in a GEOTIFF standard by DGIWG.
448
				50909 => 'GEO_METADATA',                       // This private tag is used in a GEOTIFF standard by DGIWG.
449
450
				// EXIF tags - https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html
451
				33434 => 'ExposureTime',                               // Exposure time, given in seconds.
452
				33437 => 'FNumber',                                    // The F number.
453
				34850 => 'ExposureProgram',                            // The class of the program used by the camera to set exposure when the picture is taken.
454
				34852 => 'SpectralSensitivity',                        // Indicates the spectral sensitivity of each channel of the camera used.
455
				34855 => 'ISOSpeedRatings',                            // Indicates the ISO Speed and ISO Latitude of the camera or input device as specified in ISO 12232.
456
				34856 => 'OECF',                                       // Indicates the Opto-Electric Conversion Function (OECF) specified in ISO 14524.
457
				36864 => 'ExifVersion',                                // The version of the supported Exif standard.
458
				36867 => 'DateTimeOriginal',                           // The date and time when the original image data was generated.
459
				36868 => 'DateTimeDigitized',                          // The date and time when the image was stored as digital data.
460
				37121 => 'ComponentsConfiguration',                    // Specific to compressed data; specifies the channels and complements PhotometricInterpretation
461
				37122 => 'CompressedBitsPerPixel',                     // Specific to compressed data; states the compressed bits per pixel.
462
				37377 => 'ShutterSpeedValue',                          // Shutter speed.
463
				37378 => 'ApertureValue',                              // The lens aperture.
464
				37379 => 'BrightnessValue',                            // The value of brightness.
465
				37380 => 'ExposureBiasValue',                          // The exposure bias.
466
				37381 => 'MaxApertureValue',                           // The smallest F number of the lens.
467
				37382 => 'SubjectDistance',                            // The distance to the subject, given in meters.
468
				37383 => 'MeteringMode',                               // The metering mode.
469
				37384 => 'LightSource',                                // The kind of light source.
470
				37385 => 'Flash',                                      // Indicates the status of flash when the image was shot.
471
				37386 => 'FocalLength',                                // The actual focal length of the lens, in mm.
472
				37396 => 'SubjectArea',                                // Indicates the location and area of the main subject in the overall scene.
473
				37500 => 'MakerNote',                                  // Manufacturer specific information.
474
				37510 => 'UserComment',                                // Keywords or comments on the image; complements ImageDescription.
475
				37520 => 'SubsecTime',                                 // A tag used to record fractions of seconds for the DateTime tag.
476
				37521 => 'SubsecTimeOriginal',                         // A tag used to record fractions of seconds for the DateTimeOriginal tag.
477
				37522 => 'SubsecTimeDigitized',                        // A tag used to record fractions of seconds for the DateTimeDigitized tag.
478
				40960 => 'FlashpixVersion',                            // The Flashpix format version supported by a FPXR file.
479
				40961 => 'ColorSpace',                                 // The color space information tag is always recorded as the color space specifier.
480
				40962 => 'PixelXDimension',                            // Specific to compressed data; the valid width of the meaningful image.
481
				40963 => 'PixelYDimension',                            // Specific to compressed data; the valid height of the meaningful image.
482
				40964 => 'RelatedSoundFile',                           // Used to record the name of an audio file related to the image data.
483
				41483 => 'FlashEnergy',                                // Indicates the strobe energy at the time the image is captured, as measured in Beam Candle Power Seconds
484
				41484 => 'SpatialFrequencyResponse',                   // Records the camera or input device spatial frequency table and SFR values in the direction of image width, image height, and diagonal direction, as specified in ISO 12233.
485
				41486 => 'FocalPlaneXResolution',                      // Indicates the number of pixels in the image width (X) direction per FocalPlaneResolutionUnit on the camera focal plane.
486
				41487 => 'FocalPlaneYResolution',                      // Indicates the number of pixels in the image height (Y) direction per FocalPlaneResolutionUnit on the camera focal plane.
487
				41488 => 'FocalPlaneResolutionUnit',                   // Indicates the unit for measuring FocalPlaneXResolution and FocalPlaneYResolution.
488
				41492 => 'SubjectLocation',                            // Indicates the location of the main subject in the scene.
489
				41493 => 'ExposureIndex',                              // Indicates the exposure index selected on the camera or input device at the time the image is captured.
490
				41495 => 'SensingMethod',                              // Indicates the image sensor type on the camera or input device.
491
				41728 => 'FileSource',                                 // Indicates the image source.
492
				41729 => 'SceneType',                                  // Indicates the type of scene.
493
				41730 => 'CFAPattern',                                 // Indicates the color filter array (CFA) geometric pattern of the image sensor when a one-chip color area sensor is used.
494
				41985 => 'CustomRendered',                             // Indicates the use of special processing on image data, such as rendering geared to output.
495
				41986 => 'ExposureMode',                               // Indicates the exposure mode set when the image was shot.
496
				41987 => 'WhiteBalance',                               // Indicates the white balance mode set when the image was shot.
497
				41988 => 'DigitalZoomRatio',                           // Indicates the digital zoom ratio when the image was shot.
498
				41989 => 'FocalLengthIn35mmFilm',                      // Indicates the equivalent focal length assuming a 35mm film camera, in mm.
499
				41990 => 'SceneCaptureType',                           // Indicates the type of scene that was shot.
500
				41991 => 'GainControl',                                // Indicates the degree of overall image gain adjustment.
501
				41992 => 'Contrast',                                   // Indicates the direction of contrast processing applied by the camera when the image was shot.
502
				41993 => 'Saturation',                                 // Indicates the direction of saturation processing applied by the camera when the image was shot.
503
				41994 => 'Sharpness',                                  // Indicates the direction of sharpness processing applied by the camera when the image was shot.
504
				41995 => 'DeviceSettingDescription',                   // This tag indicates information on the picture-taking conditions of a particular camera model.
505
				41996 => 'SubjectDistanceRange',                       // Indicates the distance to the subject.
506
				42016 => 'ImageUniqueID',                              // Indicates an identifier assigned uniquely to each image.
507
			);
508
		}
509
		return (isset($TIFFcommentName[$id]) ? $TIFFcommentName[$id] : 'unknown/invalid ('.$id.')');
510
	}
511
512
513
}
514