dpzvc-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -0
  3. package/build-style.js +42 -0
  4. package/dist/dpzvc.js +17605 -0
  5. package/dist/styles/dpzvc.css +1 -0
  6. package/dist-prod/index.html +26 -0
  7. package/dist-prod/main.js +1 -0
  8. package/dist-prod/vendor.bundle.js +1 -0
  9. package/package.json +88 -0
  10. package/src/components/Indicator/Indicator.vue +77 -0
  11. package/src/components/Indicator/index.js +153 -0
  12. package/src/components/Text/Number.vue +201 -0
  13. package/src/components/Text/index.js +7 -0
  14. package/src/components/Text/textBar.vue +142 -0
  15. package/src/components/action-sheet/actionSheet.vue +91 -0
  16. package/src/components/action-sheet/index.js +5 -0
  17. package/src/components/app.vue +66 -0
  18. package/src/components/badge/badge.vue +77 -0
  19. package/src/components/badge/index.js +5 -0
  20. package/src/components/button/button.vue +122 -0
  21. package/src/components/button/index.js +5 -0
  22. package/src/components/card/card.vue +59 -0
  23. package/src/components/card/index.js +5 -0
  24. package/src/components/cell/cell.vue +103 -0
  25. package/src/components/cell/index.js +5 -0
  26. package/src/components/cell-swipe/cell-swipe.vue +148 -0
  27. package/src/components/cell-swipe/index.js +5 -0
  28. package/src/components/checkBox/checkbox-group.vue +76 -0
  29. package/src/components/checkBox/checkbox.vue +107 -0
  30. package/src/components/checkBox/index.js +8 -0
  31. package/src/components/header/header.vue +82 -0
  32. package/src/components/header/index.js +5 -0
  33. package/src/components/loadMore/index.js +5 -0
  34. package/src/components/loadMore/loadmore.vue +293 -0
  35. package/src/components/message/confirm.js +52 -0
  36. package/src/components/message/index.js +132 -0
  37. package/src/components/message/message.vue +135 -0
  38. package/src/components/message/messageGroup.vue +74 -0
  39. package/src/components/modal/confirm.js +161 -0
  40. package/src/components/modal/index.js +63 -0
  41. package/src/components/modal/modal.vue +144 -0
  42. package/src/components/picker/area-picker/area-picker.vue +223 -0
  43. package/src/components/picker/area-picker/props.js +17 -0
  44. package/src/components/picker/date-picker/date-picker.vue +291 -0
  45. package/src/components/picker/date-picker/props.js +24 -0
  46. package/src/components/picker/index.js +5 -0
  47. package/src/components/picker/normal-picker/normal-picker.vue +107 -0
  48. package/src/components/picker/normal-picker/props.js +20 -0
  49. package/src/components/picker/picker-slot.vue +206 -0
  50. package/src/components/picker/picker.vue +111 -0
  51. package/src/components/popup/index.js +5 -0
  52. package/src/components/popup/popup.vue +117 -0
  53. package/src/components/progress/index.js +5 -0
  54. package/src/components/progress/progress.vue +77 -0
  55. package/src/components/prompt/confirm.js +174 -0
  56. package/src/components/prompt/index.js +50 -0
  57. package/src/components/prompt/prompt.vue +166 -0
  58. package/src/components/radioBox/index.js +8 -0
  59. package/src/components/radioBox/radiobox-group.vue +74 -0
  60. package/src/components/radioBox/radiobox.vue +117 -0
  61. package/src/components/rater/index.js +5 -0
  62. package/src/components/rater/rater.vue +164 -0
  63. package/src/components/slideBar/index.js +6 -0
  64. package/src/components/slideBar/slideBar.vue +269 -0
  65. package/src/components/spinner/behavior/blade.vue +22 -0
  66. package/src/components/spinner/behavior/double-bounce.vue +22 -0
  67. package/src/components/spinner/behavior/fading-circle.vue +37 -0
  68. package/src/components/spinner/behavior/snake.vue +32 -0
  69. package/src/components/spinner/behavior/triple-bounce.vue +41 -0
  70. package/src/components/spinner/index.js +5 -0
  71. package/src/components/spinner/props.js +25 -0
  72. package/src/components/spinner/spinner.vue +74 -0
  73. package/src/components/swipe/index.js +5 -0
  74. package/src/components/swipe/swipe.vue +399 -0
  75. package/src/components/switchbar/index.js +5 -0
  76. package/src/components/switchbar/switchbar.vue +83 -0
  77. package/src/components/tab/index.js +6 -0
  78. package/src/components/tab/tab.vue +95 -0
  79. package/src/components/toTop/index.js +5 -0
  80. package/src/components/toTop/topTop.vue +76 -0
  81. package/src/components/upload/index.js +5 -0
  82. package/src/components/upload/upload.vue +200 -0
  83. package/src/config/config.js +17 -0
  84. package/src/directives/clickoutside.js +32 -0
  85. package/src/directives/tranferDom.js +65 -0
  86. package/src/index.js +83 -0
  87. package/src/lib/MegaPixImage.js +253 -0
  88. package/src/lib/exif.js +808 -0
  89. package/src/main.js +76 -0
  90. package/src/mixin/emitter.js +41 -0
  91. package/src/mixin/input.js +41 -0
  92. package/src/router.js +229 -0
  93. package/src/styles/base/font.less +99 -0
  94. package/src/styles/base/reset.less +69 -0
  95. package/src/styles/base/variable.less +108 -0
  96. package/src/styles/components/actionSheet.less +43 -0
  97. package/src/styles/components/badge.less +79 -0
  98. package/src/styles/components/button.less +123 -0
  99. package/src/styles/components/card.less +31 -0
  100. package/src/styles/components/cell-swipe.less +20 -0
  101. package/src/styles/components/cell.less +71 -0
  102. package/src/styles/components/checkBox.less +111 -0
  103. package/src/styles/components/editor.less +3 -0
  104. package/src/styles/components/header.less +70 -0
  105. package/src/styles/components/indicator.less +37 -0
  106. package/src/styles/components/loadmore.less +48 -0
  107. package/src/styles/components/message.less +57 -0
  108. package/src/styles/components/modal.less +82 -0
  109. package/src/styles/components/number.less +58 -0
  110. package/src/styles/components/picker.less +150 -0
  111. package/src/styles/components/popup.less +46 -0
  112. package/src/styles/components/progress.less +50 -0
  113. package/src/styles/components/prompt.less +37 -0
  114. package/src/styles/components/radioBox.less +136 -0
  115. package/src/styles/components/slide-Bar.less +147 -0
  116. package/src/styles/components/spinner.less +328 -0
  117. package/src/styles/components/swipe.less +125 -0
  118. package/src/styles/components/switchBar.less +88 -0
  119. package/src/styles/components/tab.less +69 -0
  120. package/src/styles/components/text.less +80 -0
  121. package/src/styles/components/toTop.less +26 -0
  122. package/src/styles/components/upload.less +23 -0
  123. package/src/styles/index.less +38 -0
  124. package/src/styles/utils/1px.less +204 -0
  125. package/src/styles/utils/animation.less +131 -0
  126. package/src/styles/utils/nowrap.less +19 -0
  127. package/src/template/index.ejs +26 -0
  128. package/src/utils/util.js +203 -0
  129. package/src/vconsole-resources.min.js +6 -0
  130. package/src/vconsole-sources.min.js +6 -0
  131. package/src/vconsole.min.js +7 -0
  132. package/src/views/ActionSheet.vue +33 -0
  133. package/src/views/Badge.vue +40 -0
  134. package/src/views/Button.vue +40 -0
  135. package/src/views/Card.vue +52 -0
  136. package/src/views/Cell.vue +21 -0
  137. package/src/views/CellSwipe.vue +85 -0
  138. package/src/views/CheckBox.vue +53 -0
  139. package/src/views/Header.vue +47 -0
  140. package/src/views/Indicator.vue +69 -0
  141. package/src/views/LoadMore.vue +54 -0
  142. package/src/views/Message.vue +42 -0
  143. package/src/views/Modal.vue +32 -0
  144. package/src/views/Picker.vue +50 -0
  145. package/src/views/Popup.vue +87 -0
  146. package/src/views/Progress.vue +32 -0
  147. package/src/views/Prompt.vue +31 -0
  148. package/src/views/RadioBox.vue +55 -0
  149. package/src/views/Rater.vue +39 -0
  150. package/src/views/SlideBar.vue +47 -0
  151. package/src/views/Spinner.vue +15 -0
  152. package/src/views/Swipe.vue +34 -0
  153. package/src/views/SwitchBar.vue +36 -0
  154. package/src/views/Tab.vue +41 -0
  155. package/src/views/Text.vue +64 -0
  156. package/src/views/ToTop.vue +17 -0
  157. package/src/views/Upload.vue +44 -0
  158. package/src/views/guide.vue +159 -0
  159. package/src/views/index.vue +435 -0
  160. package/webpack.base.config.js +74 -0
  161. package/webpack.dev.config.js +67 -0
  162. package/webpack.dist.dev.config.js +44 -0
  163. package/webpack.dist.prod.config.js +50 -0
  164. package/webpack.prod.config.js +72 -0
@@ -0,0 +1,808 @@
1
+ /**
2
+ * Created by admin on 2017/5/26.
3
+ */
4
+ (function() {
5
+
6
+ var debug = false;
7
+
8
+ var root = this;
9
+
10
+ var EXIF = function(obj) {
11
+ if (obj instanceof EXIF) return obj;
12
+ if (!(this instanceof EXIF)) return new EXIF(obj);
13
+ this.EXIFwrapped = obj;
14
+ };
15
+
16
+ if (typeof exports !== 'undefined') {
17
+ if (typeof module !== 'undefined' && module.exports) {
18
+ exports = module.exports = EXIF;
19
+ }
20
+ exports.EXIF = EXIF;
21
+ } else {
22
+ root.EXIF = EXIF;
23
+ }
24
+
25
+ var ExifTags = EXIF.Tags = {
26
+
27
+ // version tags
28
+ 0x9000 : "ExifVersion", // EXIF version
29
+ 0xA000 : "FlashpixVersion", // Flashpix format version
30
+
31
+ // colorspace tags
32
+ 0xA001 : "ColorSpace", // Color space information tag
33
+
34
+ // image configuration
35
+ 0xA002 : "PixelXDimension", // Valid width of meaningful image
36
+ 0xA003 : "PixelYDimension", // Valid height of meaningful image
37
+ 0x9101 : "ComponentsConfiguration", // Information about channels
38
+ 0x9102 : "CompressedBitsPerPixel", // Compressed bits per pixel
39
+
40
+ // user information
41
+ 0x927C : "MakerNote", // Any desired information written by the manufacturer
42
+ 0x9286 : "UserComment", // Comments by user
43
+
44
+ // related file
45
+ 0xA004 : "RelatedSoundFile", // Name of related sound file
46
+
47
+ // date and time
48
+ 0x9003 : "DateTimeOriginal", // Date and time when the original image was generated
49
+ 0x9004 : "DateTimeDigitized", // Date and time when the image was stored digitally
50
+ 0x9290 : "SubsecTime", // Fractions of seconds for DateTime
51
+ 0x9291 : "SubsecTimeOriginal", // Fractions of seconds for DateTimeOriginal
52
+ 0x9292 : "SubsecTimeDigitized", // Fractions of seconds for DateTimeDigitized
53
+
54
+ // picture-taking conditions
55
+ 0x829A : "ExposureTime", // Exposure time (in seconds)
56
+ 0x829D : "FNumber", // F number
57
+ 0x8822 : "ExposureProgram", // Exposure program
58
+ 0x8824 : "SpectralSensitivity", // Spectral sensitivity
59
+ 0x8827 : "ISOSpeedRatings", // ISO speed rating
60
+ 0x8828 : "OECF", // Optoelectric conversion factor
61
+ 0x9201 : "ShutterSpeedValue", // Shutter speed
62
+ 0x9202 : "ApertureValue", // Lens aperture
63
+ 0x9203 : "BrightnessValue", // Value of brightness
64
+ 0x9204 : "ExposureBias", // Exposure bias
65
+ 0x9205 : "MaxApertureValue", // Smallest F number of lens
66
+ 0x9206 : "SubjectDistance", // Distance to subject in meters
67
+ 0x9207 : "MeteringMode", // Metering mode
68
+ 0x9208 : "LightSource", // Kind of light source
69
+ 0x9209 : "Flash", // Flash status
70
+ 0x9214 : "SubjectArea", // Location and area of main subject
71
+ 0x920A : "FocalLength", // Focal length of the lens in mm
72
+ 0xA20B : "FlashEnergy", // Strobe energy in BCPS
73
+ 0xA20C : "SpatialFrequencyResponse", //
74
+ 0xA20E : "FocalPlaneXResolution", // Number of pixels in width direction per FocalPlaneResolutionUnit
75
+ 0xA20F : "FocalPlaneYResolution", // Number of pixels in height direction per FocalPlaneResolutionUnit
76
+ 0xA210 : "FocalPlaneResolutionUnit", // Unit for measuring FocalPlaneXResolution and FocalPlaneYResolution
77
+ 0xA214 : "SubjectLocation", // Location of subject in image
78
+ 0xA215 : "ExposureIndex", // Exposure index selected on camera
79
+ 0xA217 : "SensingMethod", // Image sensor type
80
+ 0xA300 : "FileSource", // Image source (3 == DSC)
81
+ 0xA301 : "SceneType", // Scene type (1 == directly photographed)
82
+ 0xA302 : "CFAPattern", // Color filter array geometric pattern
83
+ 0xA401 : "CustomRendered", // Special processing
84
+ 0xA402 : "ExposureMode", // Exposure mode
85
+ 0xA403 : "WhiteBalance", // 1 = auto white balance, 2 = manual
86
+ 0xA404 : "DigitalZoomRation", // Digital zoom ratio
87
+ 0xA405 : "FocalLengthIn35mmFilm", // Equivalent foacl length assuming 35mm film camera (in mm)
88
+ 0xA406 : "SceneCaptureType", // Type of scene
89
+ 0xA407 : "GainControl", // Degree of overall image gain adjustment
90
+ 0xA408 : "Contrast", // Direction of contrast processing applied by camera
91
+ 0xA409 : "Saturation", // Direction of saturation processing applied by camera
92
+ 0xA40A : "Sharpness", // Direction of sharpness processing applied by camera
93
+ 0xA40B : "DeviceSettingDescription", //
94
+ 0xA40C : "SubjectDistanceRange", // Distance to subject
95
+
96
+ // other tags
97
+ 0xA005 : "InteroperabilityIFDPointer",
98
+ 0xA420 : "ImageUniqueID" // Identifier assigned uniquely to each image
99
+ };
100
+
101
+ var TiffTags = EXIF.TiffTags = {
102
+ 0x0100 : "ImageWidth",
103
+ 0x0101 : "ImageHeight",
104
+ 0x8769 : "ExifIFDPointer",
105
+ 0x8825 : "GPSInfoIFDPointer",
106
+ 0xA005 : "InteroperabilityIFDPointer",
107
+ 0x0102 : "BitsPerSample",
108
+ 0x0103 : "Compression",
109
+ 0x0106 : "PhotometricInterpretation",
110
+ 0x0112 : "Orientation",
111
+ 0x0115 : "SamplesPerPixel",
112
+ 0x011C : "PlanarConfiguration",
113
+ 0x0212 : "YCbCrSubSampling",
114
+ 0x0213 : "YCbCrPositioning",
115
+ 0x011A : "XResolution",
116
+ 0x011B : "YResolution",
117
+ 0x0128 : "ResolutionUnit",
118
+ 0x0111 : "StripOffsets",
119
+ 0x0116 : "RowsPerStrip",
120
+ 0x0117 : "StripByteCounts",
121
+ 0x0201 : "JPEGInterchangeFormat",
122
+ 0x0202 : "JPEGInterchangeFormatLength",
123
+ 0x012D : "TransferFunction",
124
+ 0x013E : "WhitePoint",
125
+ 0x013F : "PrimaryChromaticities",
126
+ 0x0211 : "YCbCrCoefficients",
127
+ 0x0214 : "ReferenceBlackWhite",
128
+ 0x0132 : "DateTime",
129
+ 0x010E : "ImageDescription",
130
+ 0x010F : "Make",
131
+ 0x0110 : "Model",
132
+ 0x0131 : "Software",
133
+ 0x013B : "Artist",
134
+ 0x8298 : "Copyright"
135
+ };
136
+
137
+ var GPSTags = EXIF.GPSTags = {
138
+ 0x0000 : "GPSVersionID",
139
+ 0x0001 : "GPSLatitudeRef",
140
+ 0x0002 : "GPSLatitude",
141
+ 0x0003 : "GPSLongitudeRef",
142
+ 0x0004 : "GPSLongitude",
143
+ 0x0005 : "GPSAltitudeRef",
144
+ 0x0006 : "GPSAltitude",
145
+ 0x0007 : "GPSTimeStamp",
146
+ 0x0008 : "GPSSatellites",
147
+ 0x0009 : "GPSStatus",
148
+ 0x000A : "GPSMeasureMode",
149
+ 0x000B : "GPSDOP",
150
+ 0x000C : "GPSSpeedRef",
151
+ 0x000D : "GPSSpeed",
152
+ 0x000E : "GPSTrackRef",
153
+ 0x000F : "GPSTrack",
154
+ 0x0010 : "GPSImgDirectionRef",
155
+ 0x0011 : "GPSImgDirection",
156
+ 0x0012 : "GPSMapDatum",
157
+ 0x0013 : "GPSDestLatitudeRef",
158
+ 0x0014 : "GPSDestLatitude",
159
+ 0x0015 : "GPSDestLongitudeRef",
160
+ 0x0016 : "GPSDestLongitude",
161
+ 0x0017 : "GPSDestBearingRef",
162
+ 0x0018 : "GPSDestBearing",
163
+ 0x0019 : "GPSDestDistanceRef",
164
+ 0x001A : "GPSDestDistance",
165
+ 0x001B : "GPSProcessingMethod",
166
+ 0x001C : "GPSAreaInformation",
167
+ 0x001D : "GPSDateStamp",
168
+ 0x001E : "GPSDifferential"
169
+ };
170
+
171
+ var StringValues = EXIF.StringValues = {
172
+ ExposureProgram : {
173
+ 0 : "Not defined",
174
+ 1 : "Manual",
175
+ 2 : "Normal program",
176
+ 3 : "Aperture priority",
177
+ 4 : "Shutter priority",
178
+ 5 : "Creative program",
179
+ 6 : "Action program",
180
+ 7 : "Portrait mode",
181
+ 8 : "Landscape mode"
182
+ },
183
+ MeteringMode : {
184
+ 0 : "Unknown",
185
+ 1 : "Average",
186
+ 2 : "CenterWeightedAverage",
187
+ 3 : "Spot",
188
+ 4 : "MultiSpot",
189
+ 5 : "Pattern",
190
+ 6 : "Partial",
191
+ 255 : "Other"
192
+ },
193
+ LightSource : {
194
+ 0 : "Unknown",
195
+ 1 : "Daylight",
196
+ 2 : "Fluorescent",
197
+ 3 : "Tungsten (incandescent light)",
198
+ 4 : "Flash",
199
+ 9 : "Fine weather",
200
+ 10 : "Cloudy weather",
201
+ 11 : "Shade",
202
+ 12 : "Daylight fluorescent (D 5700 - 7100K)",
203
+ 13 : "Day white fluorescent (N 4600 - 5400K)",
204
+ 14 : "Cool white fluorescent (W 3900 - 4500K)",
205
+ 15 : "White fluorescent (WW 3200 - 3700K)",
206
+ 17 : "Standard light A",
207
+ 18 : "Standard light B",
208
+ 19 : "Standard light C",
209
+ 20 : "D55",
210
+ 21 : "D65",
211
+ 22 : "D75",
212
+ 23 : "D50",
213
+ 24 : "ISO studio tungsten",
214
+ 255 : "Other"
215
+ },
216
+ Flash : {
217
+ 0x0000 : "Flash did not fire",
218
+ 0x0001 : "Flash fired",
219
+ 0x0005 : "Strobe return light not detected",
220
+ 0x0007 : "Strobe return light detected",
221
+ 0x0009 : "Flash fired, compulsory flash mode",
222
+ 0x000D : "Flash fired, compulsory flash mode, return light not detected",
223
+ 0x000F : "Flash fired, compulsory flash mode, return light detected",
224
+ 0x0010 : "Flash did not fire, compulsory flash mode",
225
+ 0x0018 : "Flash did not fire, auto mode",
226
+ 0x0019 : "Flash fired, auto mode",
227
+ 0x001D : "Flash fired, auto mode, return light not detected",
228
+ 0x001F : "Flash fired, auto mode, return light detected",
229
+ 0x0020 : "No flash function",
230
+ 0x0041 : "Flash fired, red-eye reduction mode",
231
+ 0x0045 : "Flash fired, red-eye reduction mode, return light not detected",
232
+ 0x0047 : "Flash fired, red-eye reduction mode, return light detected",
233
+ 0x0049 : "Flash fired, compulsory flash mode, red-eye reduction mode",
234
+ 0x004D : "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",
235
+ 0x004F : "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",
236
+ 0x0059 : "Flash fired, auto mode, red-eye reduction mode",
237
+ 0x005D : "Flash fired, auto mode, return light not detected, red-eye reduction mode",
238
+ 0x005F : "Flash fired, auto mode, return light detected, red-eye reduction mode"
239
+ },
240
+ SensingMethod : {
241
+ 1 : "Not defined",
242
+ 2 : "One-chip color area sensor",
243
+ 3 : "Two-chip color area sensor",
244
+ 4 : "Three-chip color area sensor",
245
+ 5 : "Color sequential area sensor",
246
+ 7 : "Trilinear sensor",
247
+ 8 : "Color sequential linear sensor"
248
+ },
249
+ SceneCaptureType : {
250
+ 0 : "Standard",
251
+ 1 : "Landscape",
252
+ 2 : "Portrait",
253
+ 3 : "Night scene"
254
+ },
255
+ SceneType : {
256
+ 1 : "Directly photographed"
257
+ },
258
+ CustomRendered : {
259
+ 0 : "Normal process",
260
+ 1 : "Custom process"
261
+ },
262
+ WhiteBalance : {
263
+ 0 : "Auto white balance",
264
+ 1 : "Manual white balance"
265
+ },
266
+ GainControl : {
267
+ 0 : "None",
268
+ 1 : "Low gain up",
269
+ 2 : "High gain up",
270
+ 3 : "Low gain down",
271
+ 4 : "High gain down"
272
+ },
273
+ Contrast : {
274
+ 0 : "Normal",
275
+ 1 : "Soft",
276
+ 2 : "Hard"
277
+ },
278
+ Saturation : {
279
+ 0 : "Normal",
280
+ 1 : "Low saturation",
281
+ 2 : "High saturation"
282
+ },
283
+ Sharpness : {
284
+ 0 : "Normal",
285
+ 1 : "Soft",
286
+ 2 : "Hard"
287
+ },
288
+ SubjectDistanceRange : {
289
+ 0 : "Unknown",
290
+ 1 : "Macro",
291
+ 2 : "Close view",
292
+ 3 : "Distant view"
293
+ },
294
+ FileSource : {
295
+ 3 : "DSC"
296
+ },
297
+
298
+ Components : {
299
+ 0 : "",
300
+ 1 : "Y",
301
+ 2 : "Cb",
302
+ 3 : "Cr",
303
+ 4 : "R",
304
+ 5 : "G",
305
+ 6 : "B"
306
+ }
307
+ };
308
+
309
+ function addEvent(element, event, handler) {
310
+ if (element.addEventListener) {
311
+ element.addEventListener(event, handler, false);
312
+ } else if (element.attachEvent) {
313
+ element.attachEvent("on" + event, handler);
314
+ }
315
+ }
316
+
317
+ function imageHasData(img) {
318
+ return !!(img.exifdata);
319
+ }
320
+
321
+
322
+ function base64ToArrayBuffer(base64, contentType) {
323
+ contentType = contentType || base64.match(/^data\:([^\;]+)\;base64,/mi)[1] || ''; // e.g. 'data:image/jpeg;base64,...' => 'image/jpeg'
324
+ base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, '');
325
+ var binary = atob(base64);
326
+ var len = binary.length;
327
+ var buffer = new ArrayBuffer(len);
328
+ var view = new Uint8Array(buffer);
329
+ for (var i = 0; i < len; i++) {
330
+ view[i] = binary.charCodeAt(i);
331
+ }
332
+ return buffer;
333
+ }
334
+
335
+ function objectURLToBlob(url, callback) {
336
+ var http = new XMLHttpRequest();
337
+ http.open("GET", url, true);
338
+ http.responseType = "blob";
339
+ http.onload = function(e) {
340
+ if (this.status == 200 || this.status === 0) {
341
+ callback(this.response);
342
+ }
343
+ };
344
+ http.send();
345
+ }
346
+
347
+ function getImageData(img, callback) {
348
+ function handleBinaryFile(binFile) {
349
+ var data = findEXIFinJPEG(binFile);
350
+ var iptcdata = findIPTCinJPEG(binFile);
351
+ img.exifdata = data || {};
352
+ img.iptcdata = iptcdata || {};
353
+ if (callback) {
354
+ callback.call(img);
355
+ }
356
+ }
357
+
358
+ if (img.src) {
359
+ if (/^data\:/i.test(img.src)) { // Data URI
360
+ var arrayBuffer = base64ToArrayBuffer(img.src);
361
+ handleBinaryFile(arrayBuffer);
362
+
363
+ } else if (/^blob\:/i.test(img.src)) { // Object URL
364
+ var fileReader = new FileReader();
365
+ fileReader.onload = function(e) {
366
+ handleBinaryFile(e.target.result);
367
+ };
368
+ objectURLToBlob(img.src, function (blob) {
369
+ fileReader.readAsArrayBuffer(blob);
370
+ });
371
+ } else {
372
+ var http = new XMLHttpRequest();
373
+ http.onload = function() {
374
+ if (this.status == 200 || this.status === 0) {
375
+ handleBinaryFile(http.response);
376
+ } else {
377
+ throw "Could not load image";
378
+ }
379
+ http = null;
380
+ };
381
+ http.open("GET", img.src, true);
382
+ http.responseType = "arraybuffer";
383
+ http.send(null);
384
+ }
385
+ } else if (window.FileReader && (img instanceof window.Blob || img instanceof window.File)) {
386
+ var fileReader = new FileReader();
387
+ fileReader.onload = function(e) {
388
+ if (debug) console.log("Got file of length " + e.target.result.byteLength);
389
+ handleBinaryFile(e.target.result);
390
+ };
391
+
392
+ fileReader.readAsArrayBuffer(img);
393
+ }
394
+ }
395
+
396
+ function findEXIFinJPEG(file) {
397
+ var dataView = new DataView(file);
398
+
399
+ if (debug) console.log("Got file of length " + file.byteLength);
400
+ if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) {
401
+ if (debug) console.log("Not a valid JPEG");
402
+ return false; // not a valid jpeg
403
+ }
404
+
405
+ var offset = 2,
406
+ length = file.byteLength,
407
+ marker;
408
+
409
+ while (offset < length) {
410
+ if (dataView.getUint8(offset) != 0xFF) {
411
+ if (debug) console.log("Not a valid marker at offset " + offset + ", found: " + dataView.getUint8(offset));
412
+ return false; // not a valid marker, something is wrong
413
+ }
414
+
415
+ marker = dataView.getUint8(offset + 1);
416
+ if (debug) console.log(marker);
417
+
418
+ // we could implement handling for other markers here,
419
+ // but we're only looking for 0xFFE1 for EXIF data
420
+
421
+ if (marker == 225) {
422
+ if (debug) console.log("Found 0xFFE1 marker");
423
+
424
+ return readEXIFData(dataView, offset + 4, dataView.getUint16(offset + 2) - 2);
425
+
426
+ // offset += 2 + file.getShortAt(offset+2, true);
427
+
428
+ } else {
429
+ offset += 2 + dataView.getUint16(offset+2);
430
+ }
431
+
432
+ }
433
+
434
+ }
435
+
436
+ function findIPTCinJPEG(file) {
437
+ var dataView = new DataView(file);
438
+
439
+ if (debug) console.log("Got file of length " + file.byteLength);
440
+ if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) {
441
+ if (debug) console.log("Not a valid JPEG");
442
+ return false; // not a valid jpeg
443
+ }
444
+
445
+ var offset = 2,
446
+ length = file.byteLength;
447
+
448
+
449
+ var isFieldSegmentStart = function(dataView, offset){
450
+ return (
451
+ dataView.getUint8(offset) === 0x38 &&
452
+ dataView.getUint8(offset+1) === 0x42 &&
453
+ dataView.getUint8(offset+2) === 0x49 &&
454
+ dataView.getUint8(offset+3) === 0x4D &&
455
+ dataView.getUint8(offset+4) === 0x04 &&
456
+ dataView.getUint8(offset+5) === 0x04
457
+ );
458
+ };
459
+
460
+ while (offset < length) {
461
+
462
+ if ( isFieldSegmentStart(dataView, offset )){
463
+
464
+ // Get the length of the name header (which is padded to an even number of bytes)
465
+ var nameHeaderLength = dataView.getUint8(offset+7);
466
+ if(nameHeaderLength % 2 !== 0) nameHeaderLength += 1;
467
+ // Check for pre photoshop 6 format
468
+ if(nameHeaderLength === 0) {
469
+ // Always 4
470
+ nameHeaderLength = 4;
471
+ }
472
+
473
+ var startOffset = offset + 8 + nameHeaderLength;
474
+ var sectionLength = dataView.getUint16(offset + 6 + nameHeaderLength);
475
+
476
+ return readIPTCData(file, startOffset, sectionLength);
477
+
478
+ break;
479
+
480
+ }
481
+
482
+
483
+ // Not the marker, continue searching
484
+ offset++;
485
+
486
+ }
487
+
488
+ }
489
+ var IptcFieldMap = {
490
+ 0x78 : 'caption',
491
+ 0x6E : 'credit',
492
+ 0x19 : 'keywords',
493
+ 0x37 : 'dateCreated',
494
+ 0x50 : 'byline',
495
+ 0x55 : 'bylineTitle',
496
+ 0x7A : 'captionWriter',
497
+ 0x69 : 'headline',
498
+ 0x74 : 'copyright',
499
+ 0x0F : 'category'
500
+ };
501
+ function readIPTCData(file, startOffset, sectionLength){
502
+ var dataView = new DataView(file);
503
+ var data = {};
504
+ var fieldValue, fieldName, dataSize, segmentType, segmentSize;
505
+ var segmentStartPos = startOffset;
506
+ while(segmentStartPos < startOffset+sectionLength) {
507
+ if(dataView.getUint8(segmentStartPos) === 0x1C && dataView.getUint8(segmentStartPos+1) === 0x02){
508
+ segmentType = dataView.getUint8(segmentStartPos+2);
509
+ if(segmentType in IptcFieldMap) {
510
+ dataSize = dataView.getInt16(segmentStartPos+3);
511
+ segmentSize = dataSize + 5;
512
+ fieldName = IptcFieldMap[segmentType];
513
+ fieldValue = getStringFromDB(dataView, segmentStartPos+5, dataSize);
514
+ // Check if we already stored a value with this name
515
+ if(data.hasOwnProperty(fieldName)) {
516
+ // Value already stored with this name, create multivalue field
517
+ if(data[fieldName] instanceof Array) {
518
+ data[fieldName].push(fieldValue);
519
+ }
520
+ else {
521
+ data[fieldName] = [data[fieldName], fieldValue];
522
+ }
523
+ }
524
+ else {
525
+ data[fieldName] = fieldValue;
526
+ }
527
+ }
528
+
529
+ }
530
+ segmentStartPos++;
531
+ }
532
+ return data;
533
+ }
534
+
535
+
536
+
537
+ function readTags(file, tiffStart, dirStart, strings, bigEnd) {
538
+ var entries = file.getUint16(dirStart, !bigEnd),
539
+ tags = {},
540
+ entryOffset, tag,
541
+ i;
542
+
543
+ for (i=0;i<entries;i++) {
544
+ entryOffset = dirStart + i*12 + 2;
545
+ tag = strings[file.getUint16(entryOffset, !bigEnd)];
546
+ if (!tag && debug) console.log("Unknown tag: " + file.getUint16(entryOffset, !bigEnd));
547
+ tags[tag] = readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd);
548
+ }
549
+ return tags;
550
+ }
551
+
552
+
553
+ function readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd) {
554
+ var type = file.getUint16(entryOffset+2, !bigEnd),
555
+ numValues = file.getUint32(entryOffset+4, !bigEnd),
556
+ valueOffset = file.getUint32(entryOffset+8, !bigEnd) + tiffStart,
557
+ offset,
558
+ vals, val, n,
559
+ numerator, denominator;
560
+
561
+ switch (type) {
562
+ case 1: // byte, 8-bit unsigned int
563
+ case 7: // undefined, 8-bit byte, value depending on field
564
+ if (numValues == 1) {
565
+ return file.getUint8(entryOffset + 8, !bigEnd);
566
+ } else {
567
+ offset = numValues > 4 ? valueOffset : (entryOffset + 8);
568
+ vals = [];
569
+ for (n=0;n<numValues;n++) {
570
+ vals[n] = file.getUint8(offset + n);
571
+ }
572
+ return vals;
573
+ }
574
+
575
+ case 2: // ascii, 8-bit byte
576
+ offset = numValues > 4 ? valueOffset : (entryOffset + 8);
577
+ return getStringFromDB(file, offset, numValues-1);
578
+
579
+ case 3: // short, 16 bit int
580
+ if (numValues == 1) {
581
+ return file.getUint16(entryOffset + 8, !bigEnd);
582
+ } else {
583
+ offset = numValues > 2 ? valueOffset : (entryOffset + 8);
584
+ vals = [];
585
+ for (n=0;n<numValues;n++) {
586
+ vals[n] = file.getUint16(offset + 2*n, !bigEnd);
587
+ }
588
+ return vals;
589
+ }
590
+
591
+ case 4: // long, 32 bit int
592
+ if (numValues == 1) {
593
+ return file.getUint32(entryOffset + 8, !bigEnd);
594
+ } else {
595
+ vals = [];
596
+ for (n=0;n<numValues;n++) {
597
+ vals[n] = file.getUint32(valueOffset + 4*n, !bigEnd);
598
+ }
599
+ return vals;
600
+ }
601
+
602
+ case 5: // rational = two long values, first is numerator, second is denominator
603
+ if (numValues == 1) {
604
+ numerator = file.getUint32(valueOffset, !bigEnd);
605
+ denominator = file.getUint32(valueOffset+4, !bigEnd);
606
+ val = new Number(numerator / denominator);
607
+ val.numerator = numerator;
608
+ val.denominator = denominator;
609
+ return val;
610
+ } else {
611
+ vals = [];
612
+ for (n=0;n<numValues;n++) {
613
+ numerator = file.getUint32(valueOffset + 8*n, !bigEnd);
614
+ denominator = file.getUint32(valueOffset+4 + 8*n, !bigEnd);
615
+ vals[n] = new Number(numerator / denominator);
616
+ vals[n].numerator = numerator;
617
+ vals[n].denominator = denominator;
618
+ }
619
+ return vals;
620
+ }
621
+
622
+ case 9: // slong, 32 bit signed int
623
+ if (numValues == 1) {
624
+ return file.getInt32(entryOffset + 8, !bigEnd);
625
+ } else {
626
+ vals = [];
627
+ for (n=0;n<numValues;n++) {
628
+ vals[n] = file.getInt32(valueOffset + 4*n, !bigEnd);
629
+ }
630
+ return vals;
631
+ }
632
+
633
+ case 10: // signed rational, two slongs, first is numerator, second is denominator
634
+ if (numValues == 1) {
635
+ return file.getInt32(valueOffset, !bigEnd) / file.getInt32(valueOffset+4, !bigEnd);
636
+ } else {
637
+ vals = [];
638
+ for (n=0;n<numValues;n++) {
639
+ vals[n] = file.getInt32(valueOffset + 8*n, !bigEnd) / file.getInt32(valueOffset+4 + 8*n, !bigEnd);
640
+ }
641
+ return vals;
642
+ }
643
+ }
644
+ }
645
+
646
+ function getStringFromDB(buffer, start, length) {
647
+ var outstr = "";
648
+ for (n = start; n < start+length; n++) {
649
+ outstr += String.fromCharCode(buffer.getUint8(n));
650
+ }
651
+ return outstr;
652
+ }
653
+
654
+ function readEXIFData(file, start) {
655
+ if (getStringFromDB(file, start, 4) != "Exif") {
656
+ if (debug) console.log("Not valid EXIF data! " + getStringFromDB(file, start, 4));
657
+ return false;
658
+ }
659
+
660
+ var bigEnd,
661
+ tags, tag,
662
+ exifData, gpsData,
663
+ tiffOffset = start + 6;
664
+
665
+ // test for TIFF validity and endianness
666
+ if (file.getUint16(tiffOffset) == 0x4949) {
667
+ bigEnd = false;
668
+ } else if (file.getUint16(tiffOffset) == 0x4D4D) {
669
+ bigEnd = true;
670
+ } else {
671
+ if (debug) console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)");
672
+ return false;
673
+ }
674
+
675
+ if (file.getUint16(tiffOffset+2, !bigEnd) != 0x002A) {
676
+ if (debug) console.log("Not valid TIFF data! (no 0x002A)");
677
+ return false;
678
+ }
679
+
680
+ var firstIFDOffset = file.getUint32(tiffOffset+4, !bigEnd);
681
+
682
+ if (firstIFDOffset < 0x00000008) {
683
+ if (debug) console.log("Not valid TIFF data! (First offset less than 8)", file.getUint32(tiffOffset+4, !bigEnd));
684
+ return false;
685
+ }
686
+
687
+ tags = readTags(file, tiffOffset, tiffOffset + firstIFDOffset, TiffTags, bigEnd);
688
+
689
+ if (tags.ExifIFDPointer) {
690
+ exifData = readTags(file, tiffOffset, tiffOffset + tags.ExifIFDPointer, ExifTags, bigEnd);
691
+ for (tag in exifData) {
692
+ switch (tag) {
693
+ case "LightSource" :
694
+ case "Flash" :
695
+ case "MeteringMode" :
696
+ case "ExposureProgram" :
697
+ case "SensingMethod" :
698
+ case "SceneCaptureType" :
699
+ case "SceneType" :
700
+ case "CustomRendered" :
701
+ case "WhiteBalance" :
702
+ case "GainControl" :
703
+ case "Contrast" :
704
+ case "Saturation" :
705
+ case "Sharpness" :
706
+ case "SubjectDistanceRange" :
707
+ case "FileSource" :
708
+ exifData[tag] = StringValues[tag][exifData[tag]];
709
+ break;
710
+
711
+ case "ExifVersion" :
712
+ case "FlashpixVersion" :
713
+ exifData[tag] = String.fromCharCode(exifData[tag][0], exifData[tag][1], exifData[tag][2], exifData[tag][3]);
714
+ break;
715
+
716
+ case "ComponentsConfiguration" :
717
+ exifData[tag] =
718
+ StringValues.Components[exifData[tag][0]] +
719
+ StringValues.Components[exifData[tag][1]] +
720
+ StringValues.Components[exifData[tag][2]] +
721
+ StringValues.Components[exifData[tag][3]];
722
+ break;
723
+ }
724
+ tags[tag] = exifData[tag];
725
+ }
726
+ }
727
+
728
+ if (tags.GPSInfoIFDPointer) {
729
+ gpsData = readTags(file, tiffOffset, tiffOffset + tags.GPSInfoIFDPointer, GPSTags, bigEnd);
730
+ for (tag in gpsData) {
731
+ switch (tag) {
732
+ case "GPSVersionID" :
733
+ gpsData[tag] = gpsData[tag][0] +
734
+ "." + gpsData[tag][1] +
735
+ "." + gpsData[tag][2] +
736
+ "." + gpsData[tag][3];
737
+ break;
738
+ }
739
+ tags[tag] = gpsData[tag];
740
+ }
741
+ }
742
+
743
+ return tags;
744
+ }
745
+
746
+ EXIF.getData = function(img, callback) {
747
+ if ((img instanceof Image || img instanceof HTMLImageElement) && !img.complete) return false;
748
+
749
+ if (!imageHasData(img)) {
750
+ getImageData(img, callback);
751
+ } else {
752
+
753
+ if (callback) {
754
+ callback.call(img);
755
+ }
756
+ }
757
+ return true;
758
+ }
759
+
760
+ EXIF.getTag = function(img, tag) {
761
+ if (!imageHasData(img)) return;
762
+ return img.exifdata[tag];
763
+ }
764
+
765
+ EXIF.getAllTags = function(img) {
766
+ if (!imageHasData(img)) return {};
767
+ var a,
768
+ data = img.exifdata,
769
+ tags = {};
770
+ for (a in data) {
771
+ if (data.hasOwnProperty(a)) {
772
+ tags[a] = data[a];
773
+ }
774
+ }
775
+ return tags;
776
+ }
777
+
778
+ EXIF.pretty = function(img) {
779
+ if (!imageHasData(img)) return "";
780
+ var a,
781
+ data = img.exifdata,
782
+ strPretty = "";
783
+ for (a in data) {
784
+ if (data.hasOwnProperty(a)) {
785
+ if (typeof data[a] == "object") {
786
+ if (data[a] instanceof Number) {
787
+ strPretty += a + " : " + data[a] + " [" + data[a].numerator + "/" + data[a].denominator + "]\r\n";
788
+ } else {
789
+ strPretty += a + " : [" + data[a].length + " values]\r\n";
790
+ }
791
+ } else {
792
+ strPretty += a + " : " + data[a] + "\r\n";
793
+ }
794
+ }
795
+ }
796
+ return strPretty;
797
+ }
798
+
799
+ EXIF.readFromBinaryFile = function(file) {
800
+ return findEXIFinJPEG(file);
801
+ }
802
+
803
+ if (typeof define === 'function' && define.amd) {
804
+ define('exif-js', [], function() {
805
+ return EXIF;
806
+ });
807
+ }
808
+ }.call(this));