Comments (4)
@rad182 would your s3 object be a raw file?
from extractd.
@przemyslawpluta yes. cr2, nef and dng
is this possible?
from extractd.
It could work with accepting buffer, which would be saved as a file and processed to generate preview.
from extractd.
Below should work with exiftool directly ...
const fs = require('fs');
const util = require('util');
const stream = require('stream');
const spawn = require('child_process').spawn;
const temp = require('temp-dir');
const pipeline = util.promisify(stream.pipeline);
const marker = '{ready}';
const terminate = ['-stay_open', 'false'].join('\n');
const action = ['-json', '-JpgFromRaw', '-b', '-', '-execute'].join('\n');
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function stripReadyEnd(done = false) {
const trans = new stream.Transform({
transform(chunk, encoding, callback) {
if (encoding === 'buffer') {
if (chunk.includes(marker)) {
chunk = chunk.slice(0, chunk.indexOf(marker));
done = true;
}
callback(null, chunk);
if (done) {
trans.end();
}
}
}
});
return trans;
}
function streamToExif(target, act, close = false, args = temp + '/args.txt') {
const argsFile = fs.createWriteStream(args);
const exiftool = spawn('exiftool', ['-stay_open', 'true', '-@', args]);
exiftool.stdout.on('data', data => {
const id = data.toString();
const isReady = id.substring(id.length - 8);
if (isReady.includes(marker) && close) {
argsFile.write(terminate + '\n');
}
});
fs.createReadStream(target).pipe(exiftool.stdin);
argsFile.write(act + '\n');
return exiftool.stdout;
}
(async () => {
await pipeline(streamToExif('nikon_d850_01.nef', action), stripReadyEnd(), fs.createWriteStream('nikon_d850_01.json'));
await pipeline(streamToExif('panasonic_s1r_01.rw2', action), stripReadyEnd(), fs.createWriteStream('panasonic_s1r_01.json'));
await pipeline(streamToExif('canon_eos_1d_x_mark_iii_01.cr3', action), stripReadyEnd(), fs.createWriteStream('canon_eos_1d_x_mark_iii_01.json'));
await timeout(1000);
await pipeline(streamToExif('nikon_z7_ii_01.nef', action), stripReadyEnd(), fs.createWriteStream('nikon_z7_ii_01.json'));
await timeout(1000);
await pipeline(streamToExif('sony_a7r_iii_01.arw', action, true), stripReadyEnd(), fs.createWriteStream('sony_a7r_iii_01.json'));
})();
from extractd.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extractd.