rails-jquery-fileupload 1.0.2

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 (27) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +67 -0
  3. data/Rakefile +15 -0
  4. data/lib/jquery/fileupload/rails/engine.rb +8 -0
  5. data/lib/jquery/fileupload/rails/middleware.rb +59 -0
  6. data/lib/jquery/fileupload/rails/upload.rb +3 -0
  7. data/lib/jquery/fileupload/rails/version.rb +7 -0
  8. data/lib/rails-jquery-fileupload.rb +8 -0
  9. data/vendor/assets/images/loading.gif +0 -0
  10. data/vendor/assets/javascripts/jquery-fileupload/all.js +13 -0
  11. data/vendor/assets/javascripts/jquery-fileupload/basic.js +4 -0
  12. data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.postmessage-transport.js +117 -0
  13. data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js +87 -0
  14. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-audio.js +106 -0
  15. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-image.js +309 -0
  16. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js +172 -0
  17. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js +699 -0
  18. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js +119 -0
  19. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-video.js +106 -0
  20. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js +1420 -0
  21. data/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js +214 -0
  22. data/vendor/assets/javascripts/jquery-fileupload/locale.js +29 -0
  23. data/vendor/assets/javascripts/jquery-fileupload/vendor/canvas-to-blob.js +95 -0
  24. data/vendor/assets/javascripts/jquery-fileupload/vendor/jquery.ui.widget.js +530 -0
  25. data/vendor/assets/javascripts/jquery-fileupload/vendor/load-image.js +1446 -0
  26. data/vendor/assets/javascripts/jquery-fileupload/vendor/tmpl.js +87 -0
  27. metadata +111 -0
@@ -0,0 +1,1446 @@
1
+ /*
2
+ * JavaScript Load Image 1.9.0
3
+ * https://github.com/blueimp/JavaScript-Load-Image
4
+ *
5
+ * Copyright 2011, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /*jslint nomen: true */
13
+ /*global define, window, document, URL, webkitURL, Blob, File, FileReader */
14
+
15
+ (function ($) {
16
+ 'use strict';
17
+
18
+ // Loads an image for a given File object.
19
+ // Invokes the callback with an img or optional canvas
20
+ // element (if supported by the browser) as parameter:
21
+ var loadImage = function (file, callback, options) {
22
+ var img = document.createElement('img'),
23
+ url,
24
+ oUrl;
25
+ img.onerror = callback;
26
+ img.onload = function () {
27
+ if (oUrl && !(options && options.noRevoke)) {
28
+ loadImage.revokeObjectURL(oUrl);
29
+ }
30
+ if (callback) {
31
+ callback(loadImage.scale(img, options));
32
+ }
33
+ };
34
+ if (loadImage.isInstanceOf('Blob', file) ||
35
+ // Files are also Blob instances, but some browsers
36
+ // (Firefox 3.6) support the File API but not Blobs:
37
+ loadImage.isInstanceOf('File', file)) {
38
+ url = oUrl = loadImage.createObjectURL(file);
39
+ // Store the file type for resize processing:
40
+ img._type = file.type;
41
+ } else if (typeof file === 'string') {
42
+ url = file;
43
+ if (options && options.crossOrigin) {
44
+ img.crossOrigin = options.crossOrigin;
45
+ }
46
+ } else {
47
+ return false;
48
+ }
49
+ if (url) {
50
+ img.src = url;
51
+ return img;
52
+ }
53
+ return loadImage.readFile(file, function (e) {
54
+ var target = e.target;
55
+ if (target && target.result) {
56
+ img.src = target.result;
57
+ } else {
58
+ if (callback) {
59
+ callback(e);
60
+ }
61
+ }
62
+ });
63
+ },
64
+ // The check for URL.revokeObjectURL fixes an issue with Opera 12,
65
+ // which provides URL.createObjectURL but doesn't properly implement it:
66
+ urlAPI = (window.createObjectURL && window) ||
67
+ (window.URL && URL.revokeObjectURL && URL) ||
68
+ (window.webkitURL && webkitURL);
69
+
70
+ loadImage.isInstanceOf = function (type, obj) {
71
+ // Cross-frame instanceof check
72
+ return Object.prototype.toString.call(obj) === '[object ' + type + ']';
73
+ };
74
+
75
+ // Transform image coordinates, allows to override e.g.
76
+ // the canvas orientation based on the orientation option,
77
+ // gets canvas, options passed as arguments:
78
+ loadImage.transformCoordinates = function () {
79
+ return;
80
+ };
81
+
82
+ // Returns transformed options, allows to override e.g.
83
+ // coordinate and dimension options based on the orientation:
84
+ loadImage.getTransformedOptions = function (options) {
85
+ return options;
86
+ };
87
+
88
+ // Canvas render method, allows to override the
89
+ // rendering e.g. to work around issues on iOS:
90
+ loadImage.renderImageToCanvas = function (
91
+ canvas,
92
+ img,
93
+ sourceX,
94
+ sourceY,
95
+ sourceWidth,
96
+ sourceHeight,
97
+ destX,
98
+ destY,
99
+ destWidth,
100
+ destHeight
101
+ ) {
102
+ canvas.getContext('2d').drawImage(
103
+ img,
104
+ sourceX,
105
+ sourceY,
106
+ sourceWidth,
107
+ sourceHeight,
108
+ destX,
109
+ destY,
110
+ destWidth,
111
+ destHeight
112
+ );
113
+ return canvas;
114
+ };
115
+
116
+ // This method is used to determine if the target image
117
+ // should be a canvas element:
118
+ loadImage.hasCanvasOption = function (options) {
119
+ return options.canvas || options.crop;
120
+ };
121
+
122
+ // Scales and/or crops the given image (img or canvas HTML element)
123
+ // using the given options.
124
+ // Returns a canvas object if the browser supports canvas
125
+ // and the hasCanvasOption method returns true or a canvas
126
+ // object is passed as image, else the scaled image:
127
+ loadImage.scale = function (img, options) {
128
+ options = options || {};
129
+ var canvas = document.createElement('canvas'),
130
+ useCanvas = img.getContext ||
131
+ (loadImage.hasCanvasOption(options) && canvas.getContext),
132
+ width = img.naturalWidth || img.width,
133
+ height = img.naturalHeight || img.height,
134
+ destWidth = width,
135
+ destHeight = height,
136
+ maxWidth,
137
+ maxHeight,
138
+ minWidth,
139
+ minHeight,
140
+ sourceWidth,
141
+ sourceHeight,
142
+ sourceX,
143
+ sourceY,
144
+ tmp,
145
+ scaleUp = function () {
146
+ var scale = Math.max(
147
+ (minWidth || destWidth) / destWidth,
148
+ (minHeight || destHeight) / destHeight
149
+ );
150
+ if (scale > 1) {
151
+ destWidth = Math.ceil(destWidth * scale);
152
+ destHeight = Math.ceil(destHeight * scale);
153
+ }
154
+ },
155
+ scaleDown = function () {
156
+ var scale = Math.min(
157
+ (maxWidth || destWidth) / destWidth,
158
+ (maxHeight || destHeight) / destHeight
159
+ );
160
+ if (scale < 1) {
161
+ destWidth = Math.ceil(destWidth * scale);
162
+ destHeight = Math.ceil(destHeight * scale);
163
+ }
164
+ };
165
+ if (useCanvas) {
166
+ options = loadImage.getTransformedOptions(options);
167
+ sourceX = options.left || 0;
168
+ sourceY = options.top || 0;
169
+ if (options.sourceWidth) {
170
+ sourceWidth = options.sourceWidth;
171
+ if (options.right !== undefined && options.left === undefined) {
172
+ sourceX = width - sourceWidth - options.right;
173
+ }
174
+ } else {
175
+ sourceWidth = width - sourceX - (options.right || 0);
176
+ }
177
+ if (options.sourceHeight) {
178
+ sourceHeight = options.sourceHeight;
179
+ if (options.bottom !== undefined && options.top === undefined) {
180
+ sourceY = height - sourceHeight - options.bottom;
181
+ }
182
+ } else {
183
+ sourceHeight = height - sourceY - (options.bottom || 0);
184
+ }
185
+ destWidth = sourceWidth;
186
+ destHeight = sourceHeight;
187
+ }
188
+ maxWidth = options.maxWidth;
189
+ maxHeight = options.maxHeight;
190
+ minWidth = options.minWidth;
191
+ minHeight = options.minHeight;
192
+ if (useCanvas && maxWidth && maxHeight && options.crop) {
193
+ destWidth = maxWidth;
194
+ destHeight = maxHeight;
195
+ tmp = sourceWidth / sourceHeight - maxWidth / maxHeight;
196
+ if (tmp < 0) {
197
+ sourceHeight = maxHeight * sourceWidth / maxWidth;
198
+ if (options.top === undefined && options.bottom === undefined) {
199
+ sourceY = (height - sourceHeight) / 2;
200
+ }
201
+ } else if (tmp > 0) {
202
+ sourceWidth = maxWidth * sourceHeight / maxHeight;
203
+ if (options.left === undefined && options.right === undefined) {
204
+ sourceX = (width - sourceWidth) / 2;
205
+ }
206
+ }
207
+ } else {
208
+ if (options.contain || options.cover) {
209
+ minWidth = maxWidth = maxWidth || minWidth;
210
+ minHeight = maxHeight = maxHeight || minHeight;
211
+ }
212
+ if (options.cover) {
213
+ scaleDown();
214
+ scaleUp();
215
+ } else {
216
+ scaleUp();
217
+ scaleDown();
218
+ }
219
+ }
220
+ if (useCanvas) {
221
+ canvas.width = destWidth;
222
+ canvas.height = destHeight;
223
+ loadImage.transformCoordinates(
224
+ canvas,
225
+ options
226
+ );
227
+ return loadImage.renderImageToCanvas(
228
+ canvas,
229
+ img,
230
+ sourceX,
231
+ sourceY,
232
+ sourceWidth,
233
+ sourceHeight,
234
+ 0,
235
+ 0,
236
+ destWidth,
237
+ destHeight
238
+ );
239
+ }
240
+ img.width = destWidth;
241
+ img.height = destHeight;
242
+ return img;
243
+ };
244
+
245
+ loadImage.createObjectURL = function (file) {
246
+ return urlAPI ? urlAPI.createObjectURL(file) : false;
247
+ };
248
+
249
+ loadImage.revokeObjectURL = function (url) {
250
+ return urlAPI ? urlAPI.revokeObjectURL(url) : false;
251
+ };
252
+
253
+ // Loads a given File object via FileReader interface,
254
+ // invokes the callback with the event object (load or error).
255
+ // The result can be read via event.target.result:
256
+ loadImage.readFile = function (file, callback, method) {
257
+ if (window.FileReader) {
258
+ var fileReader = new FileReader();
259
+ fileReader.onload = fileReader.onerror = callback;
260
+ method = method || 'readAsDataURL';
261
+ if (fileReader[method]) {
262
+ fileReader[method](file);
263
+ return fileReader;
264
+ }
265
+ }
266
+ return false;
267
+ };
268
+
269
+ if (typeof define === 'function' && define.amd) {
270
+ define(function () {
271
+ return loadImage;
272
+ });
273
+ } else {
274
+ $.loadImage = loadImage;
275
+ }
276
+ }(this));
277
+
278
+
279
+ /*
280
+ * JavaScript Load Image iOS scaling fixes 1.0.3
281
+ * https://github.com/blueimp/JavaScript-Load-Image
282
+ *
283
+ * Copyright 2013, Sebastian Tschan
284
+ * https://blueimp.net
285
+ *
286
+ * iOS image scaling fixes based on
287
+ * https://github.com/stomita/ios-imagefile-megapixel
288
+ *
289
+ * Licensed under the MIT license:
290
+ * http://www.opensource.org/licenses/MIT
291
+ */
292
+
293
+ /*jslint nomen: true, bitwise: true */
294
+ /*global define, window, document */
295
+
296
+ (function (factory) {
297
+ 'use strict';
298
+ if (typeof define === 'function' && define.amd) {
299
+ // Register as an anonymous AMD module:
300
+ define(['load-image'], factory);
301
+ } else {
302
+ // Browser globals:
303
+ factory(window.loadImage);
304
+ }
305
+ }(function (loadImage) {
306
+ 'use strict';
307
+
308
+ // Only apply fixes on the iOS platform:
309
+ if (!window.navigator || !window.navigator.platform ||
310
+ !(/iP(hone|od|ad)/).test(window.navigator.platform)) {
311
+ return;
312
+ }
313
+
314
+ var originalRenderMethod = loadImage.renderImageToCanvas;
315
+
316
+ // Detects subsampling in JPEG images:
317
+ loadImage.detectSubsampling = function (img) {
318
+ var canvas,
319
+ context;
320
+ if (img.width * img.height > 1024 * 1024) { // only consider mexapixel images
321
+ canvas = document.createElement('canvas');
322
+ canvas.width = canvas.height = 1;
323
+ context = canvas.getContext('2d');
324
+ context.drawImage(img, -img.width + 1, 0);
325
+ // subsampled image becomes half smaller in rendering size.
326
+ // check alpha channel value to confirm image is covering edge pixel or not.
327
+ // if alpha value is 0 image is not covering, hence subsampled.
328
+ return context.getImageData(0, 0, 1, 1).data[3] === 0;
329
+ }
330
+ return false;
331
+ };
332
+
333
+ // Detects vertical squash in JPEG images:
334
+ loadImage.detectVerticalSquash = function (img, subsampled) {
335
+ var naturalHeight = img.naturalHeight || img.height,
336
+ canvas = document.createElement('canvas'),
337
+ context = canvas.getContext('2d'),
338
+ data,
339
+ sy,
340
+ ey,
341
+ py,
342
+ alpha;
343
+ if (subsampled) {
344
+ naturalHeight /= 2;
345
+ }
346
+ canvas.width = 1;
347
+ canvas.height = naturalHeight;
348
+ context.drawImage(img, 0, 0);
349
+ data = context.getImageData(0, 0, 1, naturalHeight).data;
350
+ // search image edge pixel position in case it is squashed vertically:
351
+ sy = 0;
352
+ ey = naturalHeight;
353
+ py = naturalHeight;
354
+ while (py > sy) {
355
+ alpha = data[(py - 1) * 4 + 3];
356
+ if (alpha === 0) {
357
+ ey = py;
358
+ } else {
359
+ sy = py;
360
+ }
361
+ py = (ey + sy) >> 1;
362
+ }
363
+ return (py / naturalHeight) || 1;
364
+ };
365
+
366
+ // Renders image to canvas while working around iOS image scaling bugs:
367
+ // https://github.com/blueimp/JavaScript-Load-Image/issues/13
368
+ loadImage.renderImageToCanvas = function (
369
+ canvas,
370
+ img,
371
+ sourceX,
372
+ sourceY,
373
+ sourceWidth,
374
+ sourceHeight,
375
+ destX,
376
+ destY,
377
+ destWidth,
378
+ destHeight
379
+ ) {
380
+ if (img._type === 'image/jpeg') {
381
+ var context = canvas.getContext('2d'),
382
+ tmpCanvas = document.createElement('canvas'),
383
+ tileSize = 1024,
384
+ tmpContext = tmpCanvas.getContext('2d'),
385
+ subsampled,
386
+ vertSquashRatio,
387
+ tileX,
388
+ tileY;
389
+ tmpCanvas.width = tileSize;
390
+ tmpCanvas.height = tileSize;
391
+ context.save();
392
+ subsampled = loadImage.detectSubsampling(img);
393
+ if (subsampled) {
394
+ sourceX /= 2;
395
+ sourceY /= 2;
396
+ sourceWidth /= 2;
397
+ sourceHeight /= 2;
398
+ }
399
+ vertSquashRatio = loadImage.detectVerticalSquash(img, subsampled);
400
+ if (subsampled || vertSquashRatio !== 1) {
401
+ sourceY *= vertSquashRatio;
402
+ destWidth = Math.ceil(tileSize * destWidth / sourceWidth);
403
+ destHeight = Math.ceil(
404
+ tileSize * destHeight / sourceHeight / vertSquashRatio
405
+ );
406
+ destY = 0;
407
+ tileY = 0;
408
+ while (tileY < sourceHeight) {
409
+ destX = 0;
410
+ tileX = 0;
411
+ while (tileX < sourceWidth) {
412
+ tmpContext.clearRect(0, 0, tileSize, tileSize);
413
+ tmpContext.drawImage(
414
+ img,
415
+ sourceX,
416
+ sourceY,
417
+ sourceWidth,
418
+ sourceHeight,
419
+ -tileX,
420
+ -tileY,
421
+ sourceWidth,
422
+ sourceHeight
423
+ );
424
+ context.drawImage(
425
+ tmpCanvas,
426
+ 0,
427
+ 0,
428
+ tileSize,
429
+ tileSize,
430
+ destX,
431
+ destY,
432
+ destWidth,
433
+ destHeight
434
+ );
435
+ tileX += tileSize;
436
+ destX += destWidth;
437
+ }
438
+ tileY += tileSize;
439
+ destY += destHeight;
440
+ }
441
+ context.restore();
442
+ return canvas;
443
+ }
444
+ }
445
+ return originalRenderMethod(
446
+ canvas,
447
+ img,
448
+ sourceX,
449
+ sourceY,
450
+ sourceWidth,
451
+ sourceHeight,
452
+ destX,
453
+ destY,
454
+ destWidth,
455
+ destHeight
456
+ );
457
+ };
458
+
459
+ }));
460
+
461
+
462
+ /*
463
+ * JavaScript Load Image Orientation 1.0.0
464
+ * https://github.com/blueimp/JavaScript-Load-Image
465
+ *
466
+ * Copyright 2013, Sebastian Tschan
467
+ * https://blueimp.net
468
+ *
469
+ * Licensed under the MIT license:
470
+ * http://www.opensource.org/licenses/MIT
471
+ */
472
+
473
+ /*global define, window */
474
+
475
+ (function (factory) {
476
+ 'use strict';
477
+ if (typeof define === 'function' && define.amd) {
478
+ // Register as an anonymous AMD module:
479
+ define(['load-image'], factory);
480
+ } else {
481
+ // Browser globals:
482
+ factory(window.loadImage);
483
+ }
484
+ }(function (loadImage) {
485
+ 'use strict';
486
+
487
+ var originalHasCanvasOptionMethod = loadImage.hasCanvasOption;
488
+
489
+ // This method is used to determine if the target image
490
+ // should be a canvas element:
491
+ loadImage.hasCanvasOption = function (options) {
492
+ return originalHasCanvasOptionMethod(options) || options.orientation;
493
+ };
494
+
495
+ // Transform image orientation based on
496
+ // the given EXIF orientation option:
497
+ loadImage.transformCoordinates = function (canvas, options) {
498
+ var ctx = canvas.getContext('2d'),
499
+ width = canvas.width,
500
+ height = canvas.height,
501
+ orientation = options.orientation;
502
+ if (!orientation) {
503
+ return;
504
+ }
505
+ if (orientation > 4) {
506
+ canvas.width = height;
507
+ canvas.height = width;
508
+ }
509
+ switch (orientation) {
510
+ case 2:
511
+ // horizontal flip
512
+ ctx.translate(width, 0);
513
+ ctx.scale(-1, 1);
514
+ break;
515
+ case 3:
516
+ // 180° rotate left
517
+ ctx.translate(width, height);
518
+ ctx.rotate(Math.PI);
519
+ break;
520
+ case 4:
521
+ // vertical flip
522
+ ctx.translate(0, height);
523
+ ctx.scale(1, -1);
524
+ break;
525
+ case 5:
526
+ // vertical flip + 90 rotate right
527
+ ctx.rotate(0.5 * Math.PI);
528
+ ctx.scale(1, -1);
529
+ break;
530
+ case 6:
531
+ // 90° rotate right
532
+ ctx.rotate(0.5 * Math.PI);
533
+ ctx.translate(0, -height);
534
+ break;
535
+ case 7:
536
+ // horizontal flip + 90 rotate right
537
+ ctx.rotate(0.5 * Math.PI);
538
+ ctx.translate(width, -height);
539
+ ctx.scale(-1, 1);
540
+ break;
541
+ case 8:
542
+ // 90° rotate left
543
+ ctx.rotate(-0.5 * Math.PI);
544
+ ctx.translate(-width, 0);
545
+ break;
546
+ }
547
+ };
548
+
549
+ // Transforms coordinate and dimension options
550
+ // based on the given orientation option:
551
+ loadImage.getTransformedOptions = function (options) {
552
+ if (!options.orientation || options.orientation === 1) {
553
+ return options;
554
+ }
555
+ var newOptions = {},
556
+ i;
557
+ for (i in options) {
558
+ if (options.hasOwnProperty(i)) {
559
+ newOptions[i] = options[i];
560
+ }
561
+ }
562
+ switch (options.orientation) {
563
+ case 2:
564
+ // horizontal flip
565
+ newOptions.left = options.right;
566
+ newOptions.right = options.left;
567
+ break;
568
+ case 3:
569
+ // 180° rotate left
570
+ newOptions.left = options.right;
571
+ newOptions.top = options.bottom;
572
+ newOptions.right = options.left;
573
+ newOptions.bottom = options.top;
574
+ break;
575
+ case 4:
576
+ // vertical flip
577
+ newOptions.top = options.bottom;
578
+ newOptions.bottom = options.top;
579
+ break;
580
+ case 5:
581
+ // vertical flip + 90 rotate right
582
+ newOptions.left = options.top;
583
+ newOptions.top = options.left;
584
+ newOptions.right = options.bottom;
585
+ newOptions.bottom = options.right;
586
+ break;
587
+ case 6:
588
+ // 90° rotate right
589
+ newOptions.left = options.top;
590
+ newOptions.top = options.right;
591
+ newOptions.right = options.bottom;
592
+ newOptions.bottom = options.left;
593
+ break;
594
+ case 7:
595
+ // horizontal flip + 90 rotate right
596
+ newOptions.left = options.bottom;
597
+ newOptions.top = options.right;
598
+ newOptions.right = options.top;
599
+ newOptions.bottom = options.left;
600
+ break;
601
+ case 8:
602
+ // 90° rotate left
603
+ newOptions.left = options.bottom;
604
+ newOptions.top = options.left;
605
+ newOptions.right = options.top;
606
+ newOptions.bottom = options.right;
607
+ break;
608
+ }
609
+ if (options.orientation > 4) {
610
+ newOptions.maxWidth = options.maxHeight;
611
+ newOptions.maxHeight = options.maxWidth;
612
+ newOptions.minWidth = options.minHeight;
613
+ newOptions.minHeight = options.minWidth;
614
+ newOptions.sourceWidth = options.sourceHeight;
615
+ newOptions.sourceHeight = options.sourceWidth;
616
+ }
617
+ return newOptions;
618
+ };
619
+
620
+ }));
621
+
622
+
623
+ /*
624
+ * JavaScript Load Image Meta 1.0.1
625
+ * https://github.com/blueimp/JavaScript-Load-Image
626
+ *
627
+ * Copyright 2013, Sebastian Tschan
628
+ * https://blueimp.net
629
+ *
630
+ * Image meta data handling implementation
631
+ * based on the help and contribution of
632
+ * Achim Stöhr.
633
+ *
634
+ * Licensed under the MIT license:
635
+ * http://www.opensource.org/licenses/MIT
636
+ */
637
+
638
+ /*jslint continue:true */
639
+ /*global define, window, DataView, Blob, Uint8Array, console */
640
+
641
+ (function (factory) {
642
+ 'use strict';
643
+ if (typeof define === 'function' && define.amd) {
644
+ // Register as an anonymous AMD module:
645
+ define(['load-image'], factory);
646
+ } else {
647
+ // Browser globals:
648
+ factory(window.loadImage);
649
+ }
650
+ }(function (loadImage) {
651
+ 'use strict';
652
+
653
+ var hasblobSlice = window.Blob && (Blob.prototype.slice ||
654
+ Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
655
+
656
+ loadImage.blobSlice = hasblobSlice && function () {
657
+ var slice = this.slice || this.webkitSlice || this.mozSlice;
658
+ return slice.apply(this, arguments);
659
+ };
660
+
661
+ loadImage.metaDataParsers = {
662
+ jpeg: {
663
+ 0xffe1: [] // APP1 marker
664
+ }
665
+ };
666
+
667
+ // Parses image meta data and calls the callback with an object argument
668
+ // with the following properties:
669
+ // * imageHead: The complete image head as ArrayBuffer (Uint8Array for IE10)
670
+ // The options arguments accepts an object and supports the following properties:
671
+ // * maxMetaDataSize: Defines the maximum number of bytes to parse.
672
+ // * disableImageHead: Disables creating the imageHead property.
673
+ loadImage.parseMetaData = function (file, callback, options) {
674
+ options = options || {};
675
+ var that = this,
676
+ // 256 KiB should contain all EXIF/ICC/IPTC segments:
677
+ maxMetaDataSize = options.maxMetaDataSize || 262144,
678
+ data = {},
679
+ noMetaData = !(window.DataView && file && file.size >= 12 &&
680
+ file.type === 'image/jpeg' && loadImage.blobSlice);
681
+ if (noMetaData || !loadImage.readFile(
682
+ loadImage.blobSlice.call(file, 0, maxMetaDataSize),
683
+ function (e) {
684
+ // Note on endianness:
685
+ // Since the marker and length bytes in JPEG files are always
686
+ // stored in big endian order, we can leave the endian parameter
687
+ // of the DataView methods undefined, defaulting to big endian.
688
+ var buffer = e.target.result,
689
+ dataView = new DataView(buffer),
690
+ offset = 2,
691
+ maxOffset = dataView.byteLength - 4,
692
+ headLength = offset,
693
+ markerBytes,
694
+ markerLength,
695
+ parsers,
696
+ i;
697
+ // Check for the JPEG marker (0xffd8):
698
+ if (dataView.getUint16(0) === 0xffd8) {
699
+ while (offset < maxOffset) {
700
+ markerBytes = dataView.getUint16(offset);
701
+ // Search for APPn (0xffeN) and COM (0xfffe) markers,
702
+ // which contain application-specific meta-data like
703
+ // Exif, ICC and IPTC data and text comments:
704
+ if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) ||
705
+ markerBytes === 0xfffe) {
706
+ // The marker bytes (2) are always followed by
707
+ // the length bytes (2), indicating the length of the
708
+ // marker segment, which includes the length bytes,
709
+ // but not the marker bytes, so we add 2:
710
+ markerLength = dataView.getUint16(offset + 2) + 2;
711
+ if (offset + markerLength > dataView.byteLength) {
712
+ console.log('Invalid meta data: Invalid segment size.');
713
+ break;
714
+ }
715
+ parsers = loadImage.metaDataParsers.jpeg[markerBytes];
716
+ if (parsers) {
717
+ for (i = 0; i < parsers.length; i += 1) {
718
+ parsers[i].call(
719
+ that,
720
+ dataView,
721
+ offset,
722
+ markerLength,
723
+ data,
724
+ options
725
+ );
726
+ }
727
+ }
728
+ offset += markerLength;
729
+ headLength = offset;
730
+ } else {
731
+ // Not an APPn or COM marker, probably safe to
732
+ // assume that this is the end of the meta data
733
+ break;
734
+ }
735
+ }
736
+ // Meta length must be longer than JPEG marker (2)
737
+ // plus APPn marker (2), followed by length bytes (2):
738
+ if (!options.disableImageHead && headLength > 6) {
739
+ if (buffer.slice) {
740
+ data.imageHead = buffer.slice(0, headLength);
741
+ } else {
742
+ // Workaround for IE10, which does not yet
743
+ // support ArrayBuffer.slice:
744
+ data.imageHead = new Uint8Array(buffer)
745
+ .subarray(0, headLength);
746
+ }
747
+ }
748
+ } else {
749
+ console.log('Invalid JPEG file: Missing JPEG marker.');
750
+ }
751
+ callback(data);
752
+ },
753
+ 'readAsArrayBuffer'
754
+ )) {
755
+ callback(data);
756
+ }
757
+ };
758
+
759
+ }));
760
+
761
+
762
+ /*
763
+ * JavaScript Load Image Exif Parser 1.0.0
764
+ * https://github.com/blueimp/JavaScript-Load-Image
765
+ *
766
+ * Copyright 2013, Sebastian Tschan
767
+ * https://blueimp.net
768
+ *
769
+ * Licensed under the MIT license:
770
+ * http://www.opensource.org/licenses/MIT
771
+ */
772
+
773
+ /*jslint unparam: true */
774
+ /*global define, window, console */
775
+
776
+ (function (factory) {
777
+ 'use strict';
778
+ if (typeof define === 'function' && define.amd) {
779
+ // Register as an anonymous AMD module:
780
+ define(['load-image', 'load-image-meta'], factory);
781
+ } else {
782
+ // Browser globals:
783
+ factory(window.loadImage);
784
+ }
785
+ }(function (loadImage) {
786
+ 'use strict';
787
+
788
+ loadImage.ExifMap = function () {
789
+ return this;
790
+ };
791
+
792
+ loadImage.ExifMap.prototype.map = {
793
+ 'Orientation': 0x0112
794
+ };
795
+
796
+ loadImage.ExifMap.prototype.get = function (id) {
797
+ return this[id] || this[this.map[id]];
798
+ };
799
+
800
+ loadImage.getExifThumbnail = function (dataView, offset, length) {
801
+ var hexData,
802
+ i,
803
+ b;
804
+ if (!length || offset + length > dataView.byteLength) {
805
+ console.log('Invalid Exif data: Invalid thumbnail data.');
806
+ return;
807
+ }
808
+ hexData = [];
809
+ for (i = 0; i < length; i += 1) {
810
+ b = dataView.getUint8(offset + i);
811
+ hexData.push((b < 16 ? '0' : '') + b.toString(16));
812
+ }
813
+ return 'data:image/jpeg,%' + hexData.join('%');
814
+ };
815
+
816
+ loadImage.exifTagTypes = {
817
+ // byte, 8-bit unsigned int:
818
+ 1: {
819
+ getValue: function (dataView, dataOffset) {
820
+ return dataView.getUint8(dataOffset);
821
+ },
822
+ size: 1
823
+ },
824
+ // ascii, 8-bit byte:
825
+ 2: {
826
+ getValue: function (dataView, dataOffset) {
827
+ return String.fromCharCode(dataView.getUint8(dataOffset));
828
+ },
829
+ size: 1,
830
+ ascii: true
831
+ },
832
+ // short, 16 bit int:
833
+ 3: {
834
+ getValue: function (dataView, dataOffset, littleEndian) {
835
+ return dataView.getUint16(dataOffset, littleEndian);
836
+ },
837
+ size: 2
838
+ },
839
+ // long, 32 bit int:
840
+ 4: {
841
+ getValue: function (dataView, dataOffset, littleEndian) {
842
+ return dataView.getUint32(dataOffset, littleEndian);
843
+ },
844
+ size: 4
845
+ },
846
+ // rational = two long values, first is numerator, second is denominator:
847
+ 5: {
848
+ getValue: function (dataView, dataOffset, littleEndian) {
849
+ return dataView.getUint32(dataOffset, littleEndian) /
850
+ dataView.getUint32(dataOffset + 4, littleEndian);
851
+ },
852
+ size: 8
853
+ },
854
+ // slong, 32 bit signed int:
855
+ 9: {
856
+ getValue: function (dataView, dataOffset, littleEndian) {
857
+ return dataView.getInt32(dataOffset, littleEndian);
858
+ },
859
+ size: 4
860
+ },
861
+ // srational, two slongs, first is numerator, second is denominator:
862
+ 10: {
863
+ getValue: function (dataView, dataOffset, littleEndian) {
864
+ return dataView.getInt32(dataOffset, littleEndian) /
865
+ dataView.getInt32(dataOffset + 4, littleEndian);
866
+ },
867
+ size: 8
868
+ }
869
+ };
870
+ // undefined, 8-bit byte, value depending on field:
871
+ loadImage.exifTagTypes[7] = loadImage.exifTagTypes[1];
872
+
873
+ loadImage.getExifValue = function (dataView, tiffOffset, offset, type, length, littleEndian) {
874
+ var tagType = loadImage.exifTagTypes[type],
875
+ tagSize,
876
+ dataOffset,
877
+ values,
878
+ i,
879
+ str,
880
+ c;
881
+ if (!tagType) {
882
+ console.log('Invalid Exif data: Invalid tag type.');
883
+ return;
884
+ }
885
+ tagSize = tagType.size * length;
886
+ // Determine if the value is contained in the dataOffset bytes,
887
+ // or if the value at the dataOffset is a pointer to the actual data:
888
+ dataOffset = tagSize > 4 ?
889
+ tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
890
+ if (dataOffset + tagSize > dataView.byteLength) {
891
+ console.log('Invalid Exif data: Invalid data offset.');
892
+ return;
893
+ }
894
+ if (length === 1) {
895
+ return tagType.getValue(dataView, dataOffset, littleEndian);
896
+ }
897
+ values = [];
898
+ for (i = 0; i < length; i += 1) {
899
+ values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
900
+ }
901
+ if (tagType.ascii) {
902
+ str = '';
903
+ // Concatenate the chars:
904
+ for (i = 0; i < values.length; i += 1) {
905
+ c = values[i];
906
+ // Ignore the terminating NULL byte(s):
907
+ if (c === '\u0000') {
908
+ break;
909
+ }
910
+ str += c;
911
+ }
912
+ return str;
913
+ }
914
+ return values;
915
+ };
916
+
917
+ loadImage.parseExifTag = function (dataView, tiffOffset, offset, littleEndian, data) {
918
+ var tag = dataView.getUint16(offset, littleEndian);
919
+ data.exif[tag] = loadImage.getExifValue(
920
+ dataView,
921
+ tiffOffset,
922
+ offset,
923
+ dataView.getUint16(offset + 2, littleEndian), // tag type
924
+ dataView.getUint32(offset + 4, littleEndian), // tag length
925
+ littleEndian
926
+ );
927
+ };
928
+
929
+ loadImage.parseExifTags = function (dataView, tiffOffset, dirOffset, littleEndian, data) {
930
+ var tagsNumber,
931
+ dirEndOffset,
932
+ i;
933
+ if (dirOffset + 6 > dataView.byteLength) {
934
+ console.log('Invalid Exif data: Invalid directory offset.');
935
+ return;
936
+ }
937
+ tagsNumber = dataView.getUint16(dirOffset, littleEndian);
938
+ dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
939
+ if (dirEndOffset + 4 > dataView.byteLength) {
940
+ console.log('Invalid Exif data: Invalid directory size.');
941
+ return;
942
+ }
943
+ for (i = 0; i < tagsNumber; i += 1) {
944
+ this.parseExifTag(
945
+ dataView,
946
+ tiffOffset,
947
+ dirOffset + 2 + 12 * i, // tag offset
948
+ littleEndian,
949
+ data
950
+ );
951
+ }
952
+ // Return the offset to the next directory:
953
+ return dataView.getUint32(dirEndOffset, littleEndian);
954
+ };
955
+
956
+ loadImage.parseExifData = function (dataView, offset, length, data, options) {
957
+ if (options.disableExif) {
958
+ return;
959
+ }
960
+ var tiffOffset = offset + 10,
961
+ littleEndian,
962
+ dirOffset,
963
+ thumbnailData;
964
+ // Check for the ASCII code for "Exif" (0x45786966):
965
+ if (dataView.getUint32(offset + 4) !== 0x45786966) {
966
+ // No Exif data, might be XMP data instead
967
+ return;
968
+ }
969
+ if (tiffOffset + 8 > dataView.byteLength) {
970
+ console.log('Invalid Exif data: Invalid segment size.');
971
+ return;
972
+ }
973
+ // Check for the two null bytes:
974
+ if (dataView.getUint16(offset + 8) !== 0x0000) {
975
+ console.log('Invalid Exif data: Missing byte alignment offset.');
976
+ return;
977
+ }
978
+ // Check the byte alignment:
979
+ switch (dataView.getUint16(tiffOffset)) {
980
+ case 0x4949:
981
+ littleEndian = true;
982
+ break;
983
+ case 0x4D4D:
984
+ littleEndian = false;
985
+ break;
986
+ default:
987
+ console.log('Invalid Exif data: Invalid byte alignment marker.');
988
+ return;
989
+ }
990
+ // Check for the TIFF tag marker (0x002A):
991
+ if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
992
+ console.log('Invalid Exif data: Missing TIFF marker.');
993
+ return;
994
+ }
995
+ // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
996
+ dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
997
+ // Create the exif object to store the tags:
998
+ data.exif = new loadImage.ExifMap();
999
+ // Parse the tags of the main image directory and retrieve the
1000
+ // offset to the next directory, usually the thumbnail directory:
1001
+ dirOffset = loadImage.parseExifTags(
1002
+ dataView,
1003
+ tiffOffset,
1004
+ tiffOffset + dirOffset,
1005
+ littleEndian,
1006
+ data
1007
+ );
1008
+ if (dirOffset && !options.disableExifThumbnail) {
1009
+ thumbnailData = {exif: {}};
1010
+ dirOffset = loadImage.parseExifTags(
1011
+ dataView,
1012
+ tiffOffset,
1013
+ tiffOffset + dirOffset,
1014
+ littleEndian,
1015
+ thumbnailData
1016
+ );
1017
+ // Check for JPEG Thumbnail offset:
1018
+ if (thumbnailData.exif[0x0201]) {
1019
+ data.exif.Thumbnail = loadImage.getExifThumbnail(
1020
+ dataView,
1021
+ tiffOffset + thumbnailData.exif[0x0201],
1022
+ thumbnailData.exif[0x0202] // Thumbnail data length
1023
+ );
1024
+ }
1025
+ }
1026
+ // Check for Exif Sub IFD Pointer:
1027
+ if (data.exif[0x8769] && !options.disableExifSub) {
1028
+ loadImage.parseExifTags(
1029
+ dataView,
1030
+ tiffOffset,
1031
+ tiffOffset + data.exif[0x8769], // directory offset
1032
+ littleEndian,
1033
+ data
1034
+ );
1035
+ }
1036
+ // Check for GPS Info IFD Pointer:
1037
+ if (data.exif[0x8825] && !options.disableExifGps) {
1038
+ loadImage.parseExifTags(
1039
+ dataView,
1040
+ tiffOffset,
1041
+ tiffOffset + data.exif[0x8825], // directory offset
1042
+ littleEndian,
1043
+ data
1044
+ );
1045
+ }
1046
+ };
1047
+
1048
+ // Registers the Exif parser for the APP1 JPEG meta data segment:
1049
+ loadImage.metaDataParsers.jpeg[0xffe1].push(loadImage.parseExifData);
1050
+
1051
+ // Adds the following properties to the parseMetaData callback data:
1052
+ // * exif: The exif tags, parsed by the parseExifData method
1053
+
1054
+ // Adds the following options to the parseMetaData method:
1055
+ // * disableExif: Disables Exif parsing.
1056
+ // * disableExifThumbnail: Disables parsing of the Exif Thumbnail.
1057
+ // * disableExifSub: Disables parsing of the Exif Sub IFD.
1058
+ // * disableExifGps: Disables parsing of the Exif GPS Info IFD.
1059
+
1060
+ }));
1061
+
1062
+
1063
+ /*
1064
+ * JavaScript Load Image Exif Map 1.0.2
1065
+ * https://github.com/blueimp/JavaScript-Load-Image
1066
+ *
1067
+ * Copyright 2013, Sebastian Tschan
1068
+ * https://blueimp.net
1069
+ *
1070
+ * Exif tags mapping based on
1071
+ * https://github.com/jseidelin/exif-js
1072
+ *
1073
+ * Licensed under the MIT license:
1074
+ * http://www.opensource.org/licenses/MIT
1075
+ */
1076
+
1077
+ /*global define, window */
1078
+
1079
+ (function (factory) {
1080
+ 'use strict';
1081
+ if (typeof define === 'function' && define.amd) {
1082
+ // Register as an anonymous AMD module:
1083
+ define(['load-image', 'load-image-exif'], factory);
1084
+ } else {
1085
+ // Browser globals:
1086
+ factory(window.loadImage);
1087
+ }
1088
+ }(function (loadImage) {
1089
+ 'use strict';
1090
+
1091
+ loadImage.ExifMap.prototype.tags = {
1092
+ // =================
1093
+ // TIFF tags (IFD0):
1094
+ // =================
1095
+ 0x0100: 'ImageWidth',
1096
+ 0x0101: 'ImageHeight',
1097
+ 0x8769: 'ExifIFDPointer',
1098
+ 0x8825: 'GPSInfoIFDPointer',
1099
+ 0xA005: 'InteroperabilityIFDPointer',
1100
+ 0x0102: 'BitsPerSample',
1101
+ 0x0103: 'Compression',
1102
+ 0x0106: 'PhotometricInterpretation',
1103
+ 0x0112: 'Orientation',
1104
+ 0x0115: 'SamplesPerPixel',
1105
+ 0x011C: 'PlanarConfiguration',
1106
+ 0x0212: 'YCbCrSubSampling',
1107
+ 0x0213: 'YCbCrPositioning',
1108
+ 0x011A: 'XResolution',
1109
+ 0x011B: 'YResolution',
1110
+ 0x0128: 'ResolutionUnit',
1111
+ 0x0111: 'StripOffsets',
1112
+ 0x0116: 'RowsPerStrip',
1113
+ 0x0117: 'StripByteCounts',
1114
+ 0x0201: 'JPEGInterchangeFormat',
1115
+ 0x0202: 'JPEGInterchangeFormatLength',
1116
+ 0x012D: 'TransferFunction',
1117
+ 0x013E: 'WhitePoint',
1118
+ 0x013F: 'PrimaryChromaticities',
1119
+ 0x0211: 'YCbCrCoefficients',
1120
+ 0x0214: 'ReferenceBlackWhite',
1121
+ 0x0132: 'DateTime',
1122
+ 0x010E: 'ImageDescription',
1123
+ 0x010F: 'Make',
1124
+ 0x0110: 'Model',
1125
+ 0x0131: 'Software',
1126
+ 0x013B: 'Artist',
1127
+ 0x8298: 'Copyright',
1128
+ // ==================
1129
+ // Exif Sub IFD tags:
1130
+ // ==================
1131
+ 0x9000: 'ExifVersion', // EXIF version
1132
+ 0xA000: 'FlashpixVersion', // Flashpix format version
1133
+ 0xA001: 'ColorSpace', // Color space information tag
1134
+ 0xA002: 'PixelXDimension', // Valid width of meaningful image
1135
+ 0xA003: 'PixelYDimension', // Valid height of meaningful image
1136
+ 0xA500: 'Gamma',
1137
+ 0x9101: 'ComponentsConfiguration', // Information about channels
1138
+ 0x9102: 'CompressedBitsPerPixel', // Compressed bits per pixel
1139
+ 0x927C: 'MakerNote', // Any desired information written by the manufacturer
1140
+ 0x9286: 'UserComment', // Comments by user
1141
+ 0xA004: 'RelatedSoundFile', // Name of related sound file
1142
+ 0x9003: 'DateTimeOriginal', // Date and time when the original image was generated
1143
+ 0x9004: 'DateTimeDigitized', // Date and time when the image was stored digitally
1144
+ 0x9290: 'SubSecTime', // Fractions of seconds for DateTime
1145
+ 0x9291: 'SubSecTimeOriginal', // Fractions of seconds for DateTimeOriginal
1146
+ 0x9292: 'SubSecTimeDigitized', // Fractions of seconds for DateTimeDigitized
1147
+ 0x829A: 'ExposureTime', // Exposure time (in seconds)
1148
+ 0x829D: 'FNumber',
1149
+ 0x8822: 'ExposureProgram', // Exposure program
1150
+ 0x8824: 'SpectralSensitivity', // Spectral sensitivity
1151
+ 0x8827: 'PhotographicSensitivity', // EXIF 2.3, ISOSpeedRatings in EXIF 2.2
1152
+ 0x8828: 'OECF', // Optoelectric conversion factor
1153
+ 0x8830: 'SensitivityType',
1154
+ 0x8831: 'StandardOutputSensitivity',
1155
+ 0x8832: 'RecommendedExposureIndex',
1156
+ 0x8833: 'ISOSpeed',
1157
+ 0x8834: 'ISOSpeedLatitudeyyy',
1158
+ 0x8835: 'ISOSpeedLatitudezzz',
1159
+ 0x9201: 'ShutterSpeedValue', // Shutter speed
1160
+ 0x9202: 'ApertureValue', // Lens aperture
1161
+ 0x9203: 'BrightnessValue', // Value of brightness
1162
+ 0x9204: 'ExposureBias', // Exposure bias
1163
+ 0x9205: 'MaxApertureValue', // Smallest F number of lens
1164
+ 0x9206: 'SubjectDistance', // Distance to subject in meters
1165
+ 0x9207: 'MeteringMode', // Metering mode
1166
+ 0x9208: 'LightSource', // Kind of light source
1167
+ 0x9209: 'Flash', // Flash status
1168
+ 0x9214: 'SubjectArea', // Location and area of main subject
1169
+ 0x920A: 'FocalLength', // Focal length of the lens in mm
1170
+ 0xA20B: 'FlashEnergy', // Strobe energy in BCPS
1171
+ 0xA20C: 'SpatialFrequencyResponse',
1172
+ 0xA20E: 'FocalPlaneXResolution', // Number of pixels in width direction per FPRUnit
1173
+ 0xA20F: 'FocalPlaneYResolution', // Number of pixels in height direction per FPRUnit
1174
+ 0xA210: 'FocalPlaneResolutionUnit', // Unit for measuring the focal plane resolution
1175
+ 0xA214: 'SubjectLocation', // Location of subject in image
1176
+ 0xA215: 'ExposureIndex', // Exposure index selected on camera
1177
+ 0xA217: 'SensingMethod', // Image sensor type
1178
+ 0xA300: 'FileSource', // Image source (3 == DSC)
1179
+ 0xA301: 'SceneType', // Scene type (1 == directly photographed)
1180
+ 0xA302: 'CFAPattern', // Color filter array geometric pattern
1181
+ 0xA401: 'CustomRendered', // Special processing
1182
+ 0xA402: 'ExposureMode', // Exposure mode
1183
+ 0xA403: 'WhiteBalance', // 1 = auto white balance, 2 = manual
1184
+ 0xA404: 'DigitalZoomRatio', // Digital zoom ratio
1185
+ 0xA405: 'FocalLengthIn35mmFilm',
1186
+ 0xA406: 'SceneCaptureType', // Type of scene
1187
+ 0xA407: 'GainControl', // Degree of overall image gain adjustment
1188
+ 0xA408: 'Contrast', // Direction of contrast processing applied by camera
1189
+ 0xA409: 'Saturation', // Direction of saturation processing applied by camera
1190
+ 0xA40A: 'Sharpness', // Direction of sharpness processing applied by camera
1191
+ 0xA40B: 'DeviceSettingDescription',
1192
+ 0xA40C: 'SubjectDistanceRange', // Distance to subject
1193
+ 0xA420: 'ImageUniqueID', // Identifier assigned uniquely to each image
1194
+ 0xA430: 'CameraOwnerName',
1195
+ 0xA431: 'BodySerialNumber',
1196
+ 0xA432: 'LensSpecification',
1197
+ 0xA433: 'LensMake',
1198
+ 0xA434: 'LensModel',
1199
+ 0xA435: 'LensSerialNumber',
1200
+ // ==============
1201
+ // GPS Info tags:
1202
+ // ==============
1203
+ 0x0000: 'GPSVersionID',
1204
+ 0x0001: 'GPSLatitudeRef',
1205
+ 0x0002: 'GPSLatitude',
1206
+ 0x0003: 'GPSLongitudeRef',
1207
+ 0x0004: 'GPSLongitude',
1208
+ 0x0005: 'GPSAltitudeRef',
1209
+ 0x0006: 'GPSAltitude',
1210
+ 0x0007: 'GPSTimeStamp',
1211
+ 0x0008: 'GPSSatellites',
1212
+ 0x0009: 'GPSStatus',
1213
+ 0x000A: 'GPSMeasureMode',
1214
+ 0x000B: 'GPSDOP',
1215
+ 0x000C: 'GPSSpeedRef',
1216
+ 0x000D: 'GPSSpeed',
1217
+ 0x000E: 'GPSTrackRef',
1218
+ 0x000F: 'GPSTrack',
1219
+ 0x0010: 'GPSImgDirectionRef',
1220
+ 0x0011: 'GPSImgDirection',
1221
+ 0x0012: 'GPSMapDatum',
1222
+ 0x0013: 'GPSDestLatitudeRef',
1223
+ 0x0014: 'GPSDestLatitude',
1224
+ 0x0015: 'GPSDestLongitudeRef',
1225
+ 0x0016: 'GPSDestLongitude',
1226
+ 0x0017: 'GPSDestBearingRef',
1227
+ 0x0018: 'GPSDestBearing',
1228
+ 0x0019: 'GPSDestDistanceRef',
1229
+ 0x001A: 'GPSDestDistance',
1230
+ 0x001B: 'GPSProcessingMethod',
1231
+ 0x001C: 'GPSAreaInformation',
1232
+ 0x001D: 'GPSDateStamp',
1233
+ 0x001E: 'GPSDifferential',
1234
+ 0x001F: 'GPSHPositioningError'
1235
+ };
1236
+
1237
+ loadImage.ExifMap.prototype.stringValues = {
1238
+ ExposureProgram: {
1239
+ 0: 'Undefined',
1240
+ 1: 'Manual',
1241
+ 2: 'Normal program',
1242
+ 3: 'Aperture priority',
1243
+ 4: 'Shutter priority',
1244
+ 5: 'Creative program',
1245
+ 6: 'Action program',
1246
+ 7: 'Portrait mode',
1247
+ 8: 'Landscape mode'
1248
+ },
1249
+ MeteringMode: {
1250
+ 0: 'Unknown',
1251
+ 1: 'Average',
1252
+ 2: 'CenterWeightedAverage',
1253
+ 3: 'Spot',
1254
+ 4: 'MultiSpot',
1255
+ 5: 'Pattern',
1256
+ 6: 'Partial',
1257
+ 255: 'Other'
1258
+ },
1259
+ LightSource: {
1260
+ 0: 'Unknown',
1261
+ 1: 'Daylight',
1262
+ 2: 'Fluorescent',
1263
+ 3: 'Tungsten (incandescent light)',
1264
+ 4: 'Flash',
1265
+ 9: 'Fine weather',
1266
+ 10: 'Cloudy weather',
1267
+ 11: 'Shade',
1268
+ 12: 'Daylight fluorescent (D 5700 - 7100K)',
1269
+ 13: 'Day white fluorescent (N 4600 - 5400K)',
1270
+ 14: 'Cool white fluorescent (W 3900 - 4500K)',
1271
+ 15: 'White fluorescent (WW 3200 - 3700K)',
1272
+ 17: 'Standard light A',
1273
+ 18: 'Standard light B',
1274
+ 19: 'Standard light C',
1275
+ 20: 'D55',
1276
+ 21: 'D65',
1277
+ 22: 'D75',
1278
+ 23: 'D50',
1279
+ 24: 'ISO studio tungsten',
1280
+ 255: 'Other'
1281
+ },
1282
+ Flash: {
1283
+ 0x0000: 'Flash did not fire',
1284
+ 0x0001: 'Flash fired',
1285
+ 0x0005: 'Strobe return light not detected',
1286
+ 0x0007: 'Strobe return light detected',
1287
+ 0x0009: 'Flash fired, compulsory flash mode',
1288
+ 0x000D: 'Flash fired, compulsory flash mode, return light not detected',
1289
+ 0x000F: 'Flash fired, compulsory flash mode, return light detected',
1290
+ 0x0010: 'Flash did not fire, compulsory flash mode',
1291
+ 0x0018: 'Flash did not fire, auto mode',
1292
+ 0x0019: 'Flash fired, auto mode',
1293
+ 0x001D: 'Flash fired, auto mode, return light not detected',
1294
+ 0x001F: 'Flash fired, auto mode, return light detected',
1295
+ 0x0020: 'No flash function',
1296
+ 0x0041: 'Flash fired, red-eye reduction mode',
1297
+ 0x0045: 'Flash fired, red-eye reduction mode, return light not detected',
1298
+ 0x0047: 'Flash fired, red-eye reduction mode, return light detected',
1299
+ 0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode',
1300
+ 0x004D: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
1301
+ 0x004F: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
1302
+ 0x0059: 'Flash fired, auto mode, red-eye reduction mode',
1303
+ 0x005D: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
1304
+ 0x005F: 'Flash fired, auto mode, return light detected, red-eye reduction mode'
1305
+ },
1306
+ SensingMethod: {
1307
+ 1: 'Undefined',
1308
+ 2: 'One-chip color area sensor',
1309
+ 3: 'Two-chip color area sensor',
1310
+ 4: 'Three-chip color area sensor',
1311
+ 5: 'Color sequential area sensor',
1312
+ 7: 'Trilinear sensor',
1313
+ 8: 'Color sequential linear sensor'
1314
+ },
1315
+ SceneCaptureType: {
1316
+ 0: 'Standard',
1317
+ 1: 'Landscape',
1318
+ 2: 'Portrait',
1319
+ 3: 'Night scene'
1320
+ },
1321
+ SceneType: {
1322
+ 1: 'Directly photographed'
1323
+ },
1324
+ CustomRendered: {
1325
+ 0: 'Normal process',
1326
+ 1: 'Custom process'
1327
+ },
1328
+ WhiteBalance: {
1329
+ 0: 'Auto white balance',
1330
+ 1: 'Manual white balance'
1331
+ },
1332
+ GainControl: {
1333
+ 0: 'None',
1334
+ 1: 'Low gain up',
1335
+ 2: 'High gain up',
1336
+ 3: 'Low gain down',
1337
+ 4: 'High gain down'
1338
+ },
1339
+ Contrast: {
1340
+ 0: 'Normal',
1341
+ 1: 'Soft',
1342
+ 2: 'Hard'
1343
+ },
1344
+ Saturation: {
1345
+ 0: 'Normal',
1346
+ 1: 'Low saturation',
1347
+ 2: 'High saturation'
1348
+ },
1349
+ Sharpness: {
1350
+ 0: 'Normal',
1351
+ 1: 'Soft',
1352
+ 2: 'Hard'
1353
+ },
1354
+ SubjectDistanceRange: {
1355
+ 0: 'Unknown',
1356
+ 1: 'Macro',
1357
+ 2: 'Close view',
1358
+ 3: 'Distant view'
1359
+ },
1360
+ FileSource: {
1361
+ 3: 'DSC'
1362
+ },
1363
+ ComponentsConfiguration: {
1364
+ 0: '',
1365
+ 1: 'Y',
1366
+ 2: 'Cb',
1367
+ 3: 'Cr',
1368
+ 4: 'R',
1369
+ 5: 'G',
1370
+ 6: 'B'
1371
+ },
1372
+ Orientation: {
1373
+ 1: 'top-left',
1374
+ 2: 'top-right',
1375
+ 3: 'bottom-right',
1376
+ 4: 'bottom-left',
1377
+ 5: 'left-top',
1378
+ 6: 'right-top',
1379
+ 7: 'right-bottom',
1380
+ 8: 'left-bottom'
1381
+ }
1382
+ };
1383
+
1384
+ loadImage.ExifMap.prototype.getText = function (id) {
1385
+ var value = this.get(id);
1386
+ switch (id) {
1387
+ case 'LightSource':
1388
+ case 'Flash':
1389
+ case 'MeteringMode':
1390
+ case 'ExposureProgram':
1391
+ case 'SensingMethod':
1392
+ case 'SceneCaptureType':
1393
+ case 'SceneType':
1394
+ case 'CustomRendered':
1395
+ case 'WhiteBalance':
1396
+ case 'GainControl':
1397
+ case 'Contrast':
1398
+ case 'Saturation':
1399
+ case 'Sharpness':
1400
+ case 'SubjectDistanceRange':
1401
+ case 'FileSource':
1402
+ case 'Orientation':
1403
+ return this.stringValues[id][value];
1404
+ case 'ExifVersion':
1405
+ case 'FlashpixVersion':
1406
+ return String.fromCharCode(value[0], value[1], value[2], value[3]);
1407
+ case 'ComponentsConfiguration':
1408
+ return this.stringValues[id][value[0]] +
1409
+ this.stringValues[id][value[1]] +
1410
+ this.stringValues[id][value[2]] +
1411
+ this.stringValues[id][value[3]];
1412
+ case 'GPSVersionID':
1413
+ return value[0] + '.' + value[1] + '.' + value[2] + '.' + value[3];
1414
+ }
1415
+ return String(value);
1416
+ };
1417
+
1418
+ (function (exifMapPrototype) {
1419
+ var tags = exifMapPrototype.tags,
1420
+ map = exifMapPrototype.map,
1421
+ prop;
1422
+
1423
+ // Map the tag names to tags:
1424
+ for (prop in tags) {
1425
+ if (tags.hasOwnProperty(prop)) {
1426
+ map[tags[prop]] = prop;
1427
+ }
1428
+ }
1429
+ }(loadImage.ExifMap.prototype));
1430
+
1431
+ loadImage.ExifMap.prototype.getAll = function () {
1432
+ var map = {},
1433
+ prop,
1434
+ id;
1435
+ for (prop in this) {
1436
+ if (this.hasOwnProperty(prop)) {
1437
+ id = this.tags[prop];
1438
+ if (id) {
1439
+ map[id] = this.getText(id);
1440
+ }
1441
+ }
1442
+ }
1443
+ return map;
1444
+ };
1445
+
1446
+ }));