Skip to content

Commit a19bc3b

Browse files
committed
support all image format
1 parent 38566cd commit a19bc3b

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

Diff for: package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vigilo-webapp",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

Diff for: src/html/form.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h3>Nouvelle observation</h3>
1212
<div class="file-field input-field">
1313
<div class="btn">
1414
<span><i class="material-icons">camera_alt</i></span>
15-
<input type="file" accept="image/jpeg" class="validate" required>
15+
<input type="file" accept="image/*" class="validate" required>
1616
</div>
1717
<div class="file-path-wrapper">
1818
<label>Photo <span class="red-text">*</span></label>

Diff for: src/js/form.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ $("#modal-form input[type=file]").change(function () {
5656
var reader = new FileReader();
5757
reader.onload = function (e) {
5858

59+
// Render image preview
60+
renderImage(e.target.result);
61+
5962
// Read Exif
6063
var located = false
6164
var timestamp = false;
@@ -100,9 +103,6 @@ $("#modal-form input[type=file]").change(function () {
100103
setTime(now.getHours(), now.getMinutes())
101104
}
102105

103-
// Render image preview
104-
renderImage(e.target.result);
105-
106106

107107
}
108108
reader.readAsDataURL(input.files[0]);
@@ -111,15 +111,17 @@ $("#modal-form input[type=file]").change(function () {
111111

112112
function renderImage(src) {
113113
var image = new Image();
114-
image.crossOrigin="Anonymous";
114+
image.crossOrigin = "Anonymous";
115115
image.onload = function () {
116116
var orientation = 0;
117117

118118
if (typeof src != "string") {
119-
var exifObj = piexif.load(src);
120-
if (exifObj["0th"] !== undefined && exifObj["0th"][piexif.ImageIFD.Orientation] !== undefined) {
121-
orientation = exifObj["0th"][piexif.ImageIFD.Orientation];
122-
}
119+
try {
120+
var exifObj = piexif.load(src);
121+
if (exifObj["0th"] !== undefined && exifObj["0th"][piexif.ImageIFD.Orientation] !== undefined) {
122+
orientation = exifObj["0th"][piexif.ImageIFD.Orientation];
123+
}
124+
} catch {}
123125
}
124126

125127
var canvas = document.createElement("canvas");
@@ -392,7 +394,7 @@ $("#modal-form form").submit((e) => {
392394
modalLoader.open()
393395

394396
var key;
395-
if (LocalDataManager.isAdmin()){
397+
if (LocalDataManager.isAdmin()) {
396398
key = LocalDataManager.getAdminKey();
397399
}
398400

@@ -403,7 +405,7 @@ $("#modal-form form").submit((e) => {
403405
}
404406

405407
// Store secretId
406-
if (key === undefined){
408+
if (key === undefined) {
407409
LocalDataManager.setTokenSecretId(createResponse.token, createResponse.secretid);
408410
}
409411

0 commit comments

Comments
 (0)