forked from MikeKovarik/exifr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiptc.spec.mjs
155 lines (138 loc) · 4.89 KB
/
iptc.spec.mjs
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
import {assert, assertOutputWithoutErrors} from './test-util-core.mjs'
import {getFile} from './test-util-core.mjs'
import {testSegment, testMergeSegment, testSegmentTranslation, testImage} from './test-util-suites.mjs'
import {Exifr} from '../src/bundles/full.mjs'
import * as exifr from '../src/bundles/full.mjs'
describe('IPTC Segment', () => {
it(`#41 - APP13 Without IPTC should be discarded and not throw error`, async () => {
let options = {iptc: true, xmp: false}
let buffer = await getFile(`issue-exifr-41-Error_Segment_Unreachable.jpg`)
let output = await exifr.parse(buffer, options)
assertOutputWithoutErrors(output)
})
it(`#47 - Handles special unicode characters`, async () => {
let input = await getFile('issue-exifr-47.jpeg')
var output = await exifr.parse(input, true)
assert.equal(output.BylineTitle, '[Lerakják a síneket a Hatvani utcában]')
assert.equal(output.Keywords.slice(0, 154), 'Budapest. 5. kerület. Kossuth Lajos utca ; Budapest. 5. kerület. Szabad sajtó út 5-6. ; Budapest. 5. kerület. Március 15. tér. Belvárosi Fõplébániatemplom')
})
it(`#67 - Does not infinately loop through and cause leak`, async () => {
let input = await getFile('iptc-mess.jpg')
var output = await exifr.parse(input, true)
assert.equal(output.Byline, 'MARCO VILLANTI')
assert.isUndefined(output.City)
})
describe('options.iptc enable/disable', () => {
testSegment({
key: 'iptc',
fileWith: 'Bush-dog.jpg',
fileWithout: 'IMG_20180725_163423.jpg',
definedByDefault: false
})
})
testMergeSegment({
key: 'iptc',
file: 'Bush-dog.jpg',
properties: ['Headline', 'Credit']
})
// we won't bother implementing this for now. its way to insignificant of a use.
//testPickOrSkipTags('iptc', 'iptc-agency-photographer-example.jpg', [80, 'dateCreated'], [101, 'headline'])
testSegmentTranslation({
type: 'iptc',
file: 'Bush-dog.jpg',
tags: [
[
105, 'Headline',
], [
110, 'Credit',
],
]
})
testImage('iptc', 'Bush-dog.jpg', {
ObjectName: 'BUSH',
Category: 'A',
DateCreated: '20030830',
TimeCreated: '000000',
Byline: 'DUANE A. LAVERTY',
BylineTitle: 'STR',
City: 'WACO',
State: 'TX',
Country: 'USA',
OriginalTransmissionReference: 'TXDL102',
Headline: 'BUSH',
Credit: 'AP',
Source: 'AP',
})
it(`keywords is array`, async () => {
let options = {mergeOutput: false, iptc: true}
let input = await getFile('iptc-agency-photographer-example.jpg')
let output = await exifr.parse(input, options) || {}
assert.isArray(output.iptc.Keywords)
})
testImage('iptc', 'iptc-agency-photographer-example.jpg', {
// this does not represent all IPTC data in the file
SpecialInstructions: 'Newsmagazines Out',
DateCreated: '20090624',
Byline: 'Julie Doe',
BylineTitle: 'Mugwum contract photographer',
City: 'Washington',
Sublocation: 'Lincoln Memorial',
State: 'District of Columbia',
Country: 'United States of America',
OriginalTransmissionReference: 'Honest Abe',
Headline: 'Lincoln Memorial',
Credit: 'Mugwum Press',
Source: 'Julie Doe / Mugwum Press',
})
testImage('iptc', 'iptc-independent-photographer-example.jpg', {
// this does not represent all IPTC data in the file
ObjectName: 'drpin075402',
SpecialInstructions: 'No usage or third party sales granted without prior permission.',
DateCreated: '19851125',
Byline: 'David Riecks',
BylineTitle: 'Photographer',
City: 'Nainital',
Sublocation: 'Snow Peak',
State: 'Uttarakhand',
Country: 'India',
OriginalTransmissionReference: 'Sacred India',
Headline: 'Southern Himalayan Mountains.',
Credit: '©1985 David Riecks: www.riecks.c',
Source: 'David Riecks Photography',
CopyrightNotice: '©1985 David Riecks, All Rights Reserved',
})
testImage('iptc', 'iptc-staff-photographer-example.jpg', {
// this does not represent all IPTC data in the file
DateCreated: '20070419',
TimeCreated: '110315-0600',
Byline: 'John Doe',
BylineTitle: 'Staff Photographer',
City: 'Watseka',
Sublocation: 'Moore family farm',
State: 'Illinois',
Country: 'United States',
OriginalTransmissionReference: 'CSA farms',
Headline: 'Farmer planting onions',
Credit: 'Big Newspaper',
Source: 'John Doe / Big Newspaper',
CopyrightNotice: '©2010 Big Newspaper, all rights reserved',
Writer: 'Susan Brown'
})
testImage('iptc', 'BonTonARTSTORplusIPTC.jpg', {
// this does not represent all IPTC data in the file
DateCreated: '20071119',
Byline: 'Allan Kohl',
Headline: 'Do you know your lesson?: Tailored ensembles imagined by Jeanne Lanvin',
Credit: 'Allan Kohl; Minneapolis College of Art & Design Visual Resource Collection',
Source: 'Core 4 Sample Database (VCat)',
CopyrightNotice: 'publicDomain',
// ... and then there's more data like keywords array
})
testImage('iptc', 'issue-fast-exif-2.jpg', {
DateCreated: '20170506',
TimeCreated: '152407',
DigitalCreationDate: '20170506',
DigitalCreationTime: '152407',
Byline: 'FRPASSAQUAY'
})
})