0
什麼是正確的方式從JPEG使用JavaScript讀取JPEG註釋字段(而不是EXIF,但是COM field),特別是使用命令行上的節點?使用JavaScript從JPEG讀取JPEG註釋的最合適方法是什麼?
我發現了很多用於讀取JavaScript中EXIF數據的庫,但我還沒有找到一個用於JPEG註釋的庫。
什麼是正確的方式從JPEG使用JavaScript讀取JPEG註釋字段(而不是EXIF,但是COM field),特別是使用命令行上的節點?使用JavaScript從JPEG讀取JPEG註釋的最合適方法是什麼?
我發現了很多用於讀取JavaScript中EXIF數據的庫,但我還沒有找到一個用於JPEG註釋的庫。
掃描COM標記的輸入流。唯一的技巧是你需要識別長度字段的標記並跳過它們。
感謝user3344003上面我用node-binary此解決方案:
var binary = require('binary');
binary.parse(buffer)
// Scan for COM marker 0xfffe
.scan('precomment', new Buffer([0xff, 0xfe]))
// Get the next two bytes for the size of the comment field
.word16bu('size')
// Put the comment field in a buffer
.buffer('comment', 'size')
// Do something with the buffer
.tap(function (vars) {
console.log(vars.comment.toString('utf-8'));
});
謝謝,這個回答讓我思考了正確的方向。 –