Skip to content

Commit b96a821

Browse files
committed
Add examples for parsing Exif Thumbnail and IFDs.
1 parent 2715acb commit b96a821

1 file changed

Lines changed: 87 additions & 3 deletions

File tree

README.md

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
- [Meta data parsing](#meta-data-parsing)
4040
- [Image head](#image-head)
4141
- [Exif parser](#exif-parser)
42+
- [Exif Thumbnail](#exif-thumbnail)
43+
- [Exif IFD](#exif-ifd)
44+
- [GPSInfo IFD](#gpsinfo-ifd)
45+
- [Interoperability IFD](#interoperability-ifd)
4246
- [Exif parser options](#exif-parser-options)
4347
- [Exif writer](#exif-writer)
4448
- [IPTC parser](#iptc-parser)
@@ -463,9 +467,9 @@ By default, only the following names are mapped:
463467

464468
- `Orientation`
465469
- `Thumbnail`
466-
- `Exif`
467-
- `GPSInfo`
468-
- `Interoperability`
470+
- `Exif` (see [Exif IFD](#exif-ifd))
471+
- `GPSInfo` (see [GPSInfo IFD](#gpsinfo-ifd))
472+
- `Interoperability` (see [Interoperability IFD](#interoperability-ifd))
469473

470474
If you also include the Load Image Exif Map library, additional tag mappings
471475
become available, as well as three additional methods:
@@ -483,6 +487,86 @@ var name = data.exif.getName(0x0112) // Orientation
483487
var allTags = data.exif.getAll()
484488
```
485489

490+
#### Exif Thumbnail
491+
492+
Example code displaying a thumbnail image embedded into the Exif meta data:
493+
494+
```js
495+
loadImage(
496+
fileOrBlobOrUrl,
497+
function (img, data) {
498+
var thumbBlob = data.exif && data.exif.get('Thumbnail')
499+
if (thumbBlob) {
500+
loadImage(thumbBlob, function (thumbImage) {
501+
document.body.appendChild(thumbImage)
502+
})
503+
}
504+
},
505+
{ meta: true }
506+
)
507+
```
508+
509+
#### Exif IFD
510+
511+
Example code displaying data from the Exif IFD (Image File Directory) that
512+
contains Exif specified TIFF tags:
513+
514+
```js
515+
loadImage(
516+
fileOrBlobOrUrl,
517+
function (img, data) {
518+
var exifIFD = data.exif && data.exif.get('Exif')
519+
if (exifIFD) {
520+
// Map of all Exif IFD tags with their mapped names/text as keys/values:
521+
console.log(exifIFD.getAll())
522+
// A specific Exif IFD tag value:
523+
console.log(exifIFD.get('UserComment'))
524+
}
525+
},
526+
{ meta: true }
527+
)
528+
```
529+
530+
#### GPSInfo IFD
531+
532+
Example code displaying data from the Exif IFD (Image File Directory) that
533+
contains [GPS](https://en.wikipedia.org/wiki/Global_Positioning_System) info:
534+
535+
```js
536+
loadImage(
537+
fileOrBlobOrUrl,
538+
function (img, data) {
539+
var gpsInfo = data.exif && data.exif.get('GPSInfo')
540+
if (gpsInfo) {
541+
// Map of all GPSInfo tags with their mapped names/text as keys/values:
542+
console.log(gpsInfo.getAll())
543+
// A specific GPSInfo tag value:
544+
console.log(gpsInfo.get('GPSLatitude'))
545+
}
546+
},
547+
{ meta: true }
548+
)
549+
```
550+
551+
#### Interoperability IFD
552+
553+
Example code displaying data from the Exif IFD (Image File Directory) that
554+
contains Interoperability data:
555+
556+
```js
557+
loadImage(
558+
fileOrBlobOrUrl,
559+
function (img, data) {
560+
var interoperabilityData = data.exif && data.exif.get('Interoperability')
561+
if (interoperabilityData) {
562+
// The InteroperabilityIndex tag value:
563+
console.log(interoperabilityData.get('InteroperabilityIndex'))
564+
}
565+
},
566+
{ meta: true }
567+
)
568+
```
569+
486570
#### Exif parser options
487571

488572
The Exif parser adds additional options:

0 commit comments

Comments
 (0)