mirror of
https://github.com/voltbonn/profile-picture-generator.git
synced 2024-12-22 07:45:04 +00:00
modified the copied function, to fit the style guide
This commit is contained in:
parent
14757887e0
commit
f70c295da3
1 changed files with 28 additions and 21 deletions
49
src/App.js
49
src/App.js
|
@ -10,41 +10,48 @@ const frameSize = 1080
|
|||
|
||||
function getOrientation(file, callback) {
|
||||
// Source: http://stackoverflow.com/a/32490603
|
||||
var reader = new FileReader();
|
||||
// (With some modifications: I just made the code fit the style-guide.)
|
||||
const reader = new FileReader()
|
||||
|
||||
reader.onload = function (event) {
|
||||
var view = new DataView(event.target.result);
|
||||
const view = new DataView(event.target.result)
|
||||
|
||||
if (view.getUint16(0, false) !== 0xFFD8) return callback(-2);
|
||||
if (view.getUint16(0, false) !== 0xFFD8) {
|
||||
return callback(-2)
|
||||
}
|
||||
|
||||
var length = view.byteLength,
|
||||
offset = 2;
|
||||
const length = view.byteLength
|
||||
let offset = 2
|
||||
|
||||
while (offset < length) {
|
||||
var marker = view.getUint16(offset, false);
|
||||
offset += 2;
|
||||
const marker = view.getUint16(offset, false)
|
||||
offset += 2
|
||||
|
||||
if (marker === 0xFFE1) {
|
||||
if (view.getUint32(offset += 2, false) !== 0x45786966) {
|
||||
return callback(-1);
|
||||
return callback(-1)
|
||||
}
|
||||
var little = view.getUint16(offset += 6, false) === 0x4949;
|
||||
offset += view.getUint32(offset + 4, little);
|
||||
var tags = view.getUint16(offset, little);
|
||||
offset += 2;
|
||||
const little = view.getUint16(offset += 6, false) === 0x4949
|
||||
offset += view.getUint32(offset + 4, little)
|
||||
const tags = view.getUint16(offset, little)
|
||||
offset += 2
|
||||
|
||||
for (var i = 0; i < tags; i++)
|
||||
if (view.getUint16(offset + (i * 12), little) === 0x0112)
|
||||
return callback(view.getUint16(offset + (i * 12) + 8, little));
|
||||
for (var i = 0; i < tags; i++) {
|
||||
if (view.getUint16(offset + (i * 12), little) === 0x0112) {
|
||||
return callback(view.getUint16(offset + (i * 12) + 8, little))
|
||||
}
|
||||
}
|
||||
} else if ((marker & 0xFF00) !== 0xFF00) {
|
||||
break
|
||||
} else {
|
||||
offset += view.getUint16(offset, false)
|
||||
}
|
||||
else if ((marker & 0xFF00) !== 0xFF00) break;
|
||||
else offset += view.getUint16(offset, false);
|
||||
}
|
||||
return callback(-1);
|
||||
};
|
||||
return callback(-1)
|
||||
}
|
||||
|
||||
reader.readAsArrayBuffer(file.slice(0, 64 * 1024));
|
||||
};
|
||||
reader.readAsArrayBuffer(file.slice(0, 64 * 1024))
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [frameURL, setFrameURL] = useState(null)
|
||||
|
|
Loading…
Reference in a new issue