Comparing version 2.0.0 to 2.1.0
@@ -5,2 +5,4 @@ const fs = require('fs'); | ||
const temp = require('temp-dir'); | ||
const Readable = require('stream').Readable; | ||
const Base64Encode = require('base64-stream').Base64Encode; | ||
const shortid = require('shortid'); | ||
@@ -10,2 +12,3 @@ const ExifTool = require('exiftool-vendored').ExifTool; | ||
const stat = util.promisify(fs.lstat); | ||
const read = fs.promises.readFile; | ||
@@ -60,10 +63,37 @@ shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@'); | ||
function streamWipe(file) { | ||
const item = fs.createReadStream(file); | ||
function streamWipe(file, base64 = false, datauri = false) { | ||
const item = !base64 ? fs.createReadStream(file) : fs.createReadStream(file).pipe(new Base64Encode((!datauri ? {} : { | ||
prefix: 'data:image/jpeg;base64,' | ||
}))); | ||
if (base64) { | ||
item.path = file; | ||
} | ||
item.on('end', async () => { | ||
await outcome(remove(file)); | ||
}); | ||
return item; | ||
} | ||
async function baseCheck(file, base64 = false, datauri = false) { | ||
if (!base64) { | ||
return file; | ||
} | ||
const content = await read(file, 'base64'); | ||
await outcome(remove(file)); | ||
return (!datauri) ? content : 'data:image/jpeg;base64,' + content; | ||
} | ||
function bufferToStream(data) { | ||
const stream = new Readable(); | ||
stream.push(data); | ||
stream.push(null); | ||
return stream; | ||
} | ||
async function exists(source) { | ||
@@ -138,2 +168,6 @@ | ||
function isNormal(meta) { | ||
return (meta.result.Orientation && typeof meta.result.Orientation === 'number' && orientations[meta.result.Orientation - 1].includes('normal')) ? true : false; | ||
} | ||
async function generate(list, options = {}, exiftool = null, items = [], create = {}, main = null) { | ||
@@ -188,19 +222,36 @@ | ||
create = await outcome((master.exiftool || exiftool)[`extract${listPreviews.replace('Image', '')}`](source, preview)); | ||
if (options.base64 && isNormal(meta)) { | ||
if (create.success) { | ||
create = await outcome((master.exiftool || exiftool).extractBinaryTagToBuffer(listPreviews, source)); | ||
if (meta.result.Orientation && typeof meta.result.Orientation === 'number') { | ||
if (create.success) { | ||
await (master.exiftool || exiftool).write(preview, { | ||
Orientation: orientations[meta.result.Orientation - 1] | ||
}, ['-overwrite_original_in_place']); | ||
const content = (!options.datauri) ? create.result.toString('base64') : 'data:image/jpeg;base64,' + create.result.toString('base64'); | ||
main = { | ||
preview: !options.stream ? content : bufferToStream(content), | ||
source | ||
}; | ||
} | ||
main = { | ||
preview: !options.stream ? preview : streamWipe(preview), | ||
source | ||
}; | ||
} else { | ||
create = await outcome((master.exiftool || exiftool)[`extract${listPreviews.replace('Image', '')}`](source, preview)); | ||
if (create.success) { | ||
if (meta.result.Orientation && typeof meta.result.Orientation === 'number') { | ||
await (master.exiftool || exiftool).write(preview, { | ||
Orientation: orientations[meta.result.Orientation - 1] | ||
}, ['-overwrite_original_in_place']); | ||
} | ||
main = { | ||
preview: !options.stream ? await baseCheck(preview, options.base64, options.datauri) : streamWipe(preview, options.base64, options.datauri), | ||
source | ||
}; | ||
} | ||
} | ||
@@ -207,0 +258,0 @@ |
{ | ||
"name": "extractd", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Extract previews from DSLR and mirrorless cameras' RAW files", | ||
@@ -12,4 +12,3 @@ "main": "extractd.js", | ||
"name": "Przemyslaw Pluta", | ||
"email": "przemyslawplutadev@gmail.com", | ||
"url": "https://przemyslawpluta.com" | ||
"email": "przemyslawplutadev@gmail.com" | ||
}, | ||
@@ -41,3 +40,7 @@ "license": "MIT", | ||
"cr2", | ||
"cr3", | ||
"raf", | ||
"fff", | ||
"rwl", | ||
"x3f", | ||
"dng", | ||
@@ -51,3 +54,4 @@ "rw2", | ||
"dependencies": { | ||
"exiftool-vendored": "^14.6.0", | ||
"base64-stream": "^1.0.0", | ||
"exiftool-vendored": "^15.1.0", | ||
"shortid": "^2.2.14", | ||
@@ -54,0 +58,0 @@ "temp-dir": "^2.0.0" |
@@ -26,4 +26,8 @@ # extractd | ||
- **stream** `optional (boolean)` - by default `exif` process generates the preview file in the temp directory in the OS or in `destination` if provided; once enabled `preview` is returned as a readeble stream which source will by automatically deleted after fully piped (defaults to false). | ||
- **base64** `optional (boolean)` - returns base64 encoded preview string (defaults to false). | ||
- **datauri** `optional (boolean)` - returns datauri base64 encoded preview string (defaults to false). | ||
- **persist** `optional (boolean)` - by default `exif` process will be initialised and killed of per extractd call; with `persist` enabled same `exif` process can be used across all calls for single file and batch processing (defaults to false). | ||
Orientation of extracted images will be corrected based on metadata available in the source file. | ||
### Basic usage | ||
@@ -53,2 +57,29 @@ | ||
### Base64 usage | ||
```js | ||
const extractd = require('extractd'); | ||
(async () => { | ||
const done = await extractd.generate('/directory/nikon_d850_01.nef', { | ||
base64: true, | ||
datauri: true | ||
}); | ||
})(); | ||
``` | ||
Response `done (object)` will be similar to: | ||
```js | ||
{ | ||
preview: 'data:image/jpeg;base64,/9j/2wCEAAQGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHR...', | ||
source: '/directory/nikon_d850_01.nef' | ||
} | ||
``` | ||
- preview - datauri base64 preview image | ||
- source - location of the original RAW image | ||
### Persistent status check | ||
@@ -127,2 +158,33 @@ | ||
### Base64 stream usage | ||
```js | ||
const extractd = require('extractd'); | ||
const pipeline = require('util').promisify(require('stream').pipeline); | ||
(async () => { | ||
const done = await extractd.generate('/directory/nikon_d850_01.nef', { | ||
stream: true, | ||
base64: true, | ||
datauri: true | ||
}); | ||
await pipeline(done.preview, require('fs').createWriteStream('/my/new/directory/nikon_d850_01.txt')); | ||
})(); | ||
``` | ||
Response `done (object)` will be similar to: | ||
```js | ||
{ | ||
preview: ReadStream, | ||
source: '/directory/nikon_d850_01.nef' | ||
} | ||
``` | ||
- preview - readable datauri base64 stream | ||
- source - location of the original RAW image | ||
### Complex usage | ||
@@ -129,0 +191,0 @@ |
@@ -19,8 +19,15 @@ const fs = require('fs'); | ||
`${samples}/nikon_d850_01.nef`, | ||
`${samples}/nikon_z7_ii_01.nef`, | ||
`${samples}/canon_eos_5d_mark_iv_01.cr2`, | ||
`${samples}/canon_eos_1d_x_mark_iii_01.cr3`, | ||
`${samples}/sony_a7r_iii_01.arw`, | ||
`${samples}/sony_a9_ii_01.arw`, | ||
`${samples}/panasonic_s1r_01.rw2`, | ||
`${samples}/panasonic_lumix_gh5_ii_01.rw2`, | ||
`${samples}/pentax_k_1_mark_ii_01.dng`, | ||
`${samples}/fujifilm_x_t3_01.raf`, | ||
`${samples}/fujifilm_x_s10_01.raf`, | ||
`${samples}/leica_cl_01.dng`, | ||
`${samples}/leica_v_lux_5_01.rwl`, | ||
`${samples}/sigma_sd1_merrill_01.x3f`, | ||
`${samples}/dummyFile.nef` | ||
@@ -45,3 +52,3 @@ ]; | ||
expect(done).to.have.lengthOf(8); | ||
expect(done).to.have.lengthOf(15); | ||
@@ -63,5 +70,5 @@ }); | ||
it('nikon preview item in the array should contain objects with preview and source files', async () => { | ||
it('nikon d850 preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('nikon')).shift(); | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('nikon_d850')).shift(); | ||
@@ -81,5 +88,5 @@ expect(item).to.have.own.property('preview'); | ||
it('canon preview item in the array should contain objects with preview and source files', async () => { | ||
it('nikon z7 preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('canon')).shift(); | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('nikon_z7')).shift(); | ||
@@ -99,5 +106,5 @@ expect(item).to.have.own.property('preview'); | ||
it('sony preview item in the array should contain objects with preview and source files', async () => { | ||
it('canon eos 5d preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('sony')).shift(); | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('canon_eos_5d')).shift(); | ||
@@ -117,5 +124,5 @@ expect(item).to.have.own.property('preview'); | ||
it('panasonic preview item in the array should contain objects with preview and source files', async () => { | ||
it('canon eos 1d preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('panasonic')).shift(); | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('canon_eos_1d')).shift(); | ||
@@ -135,2 +142,70 @@ expect(item).to.have.own.property('preview'); | ||
it('sony a7r preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('sony_a7r')).shift(); | ||
expect(item).to.have.own.property('preview'); | ||
expect(item).to.have.own.property('source'); | ||
expect(path.dirname(item.source)).to.be.deep.equal(path.dirname(item.preview)); | ||
expect(path.basename(item.source, path.extname(item.source))).to.be.deep.equal(path.basename(item.preview, '.jpg')); | ||
expect(path.extname(item.preview)).to.deep.equal('.jpg'); | ||
await del(item.preview); | ||
}); | ||
it('sony a9 preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('sony_a9')).shift(); | ||
expect(item).to.have.own.property('preview'); | ||
expect(item).to.have.own.property('source'); | ||
expect(path.dirname(item.source)).to.be.deep.equal(path.dirname(item.preview)); | ||
expect(path.basename(item.source, path.extname(item.source))).to.be.deep.equal(path.basename(item.preview, '.jpg')); | ||
expect(path.extname(item.preview)).to.deep.equal('.jpg'); | ||
await del(item.preview); | ||
}); | ||
it('panasonic s1r preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('panasonic_s1r')).shift(); | ||
expect(item).to.have.own.property('preview'); | ||
expect(item).to.have.own.property('source'); | ||
expect(path.dirname(item.source)).to.be.deep.equal(path.dirname(item.preview)); | ||
expect(path.basename(item.source, path.extname(item.source))).to.be.deep.equal(path.basename(item.preview, '.jpg')); | ||
expect(path.extname(item.preview)).to.deep.equal('.jpg'); | ||
await del(item.preview); | ||
}); | ||
it('panasonic lumix preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('panasonic_lumix')).shift(); | ||
expect(item).to.have.own.property('preview'); | ||
expect(item).to.have.own.property('source'); | ||
expect(path.dirname(item.source)).to.be.deep.equal(path.dirname(item.preview)); | ||
expect(path.basename(item.source, path.extname(item.source))).to.be.deep.equal(path.basename(item.preview, '.jpg')); | ||
expect(path.extname(item.preview)).to.deep.equal('.jpg'); | ||
await del(item.preview); | ||
}); | ||
it('pentax preview item in the array should contain objects with preview and source files', async () => { | ||
@@ -153,5 +228,5 @@ | ||
it('fujifilm preview item in the array should contain objects with preview and source files', async () => { | ||
it('fujifilm x t3 preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('fujifilm')).shift(); | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('fujifilm_x_t3')).shift(); | ||
@@ -171,5 +246,5 @@ expect(item).to.have.own.property('preview'); | ||
it('leica preview item in the array should contain objects with preview and source files', async () => { | ||
it('fujifilm x s10 preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('leica')).shift(); | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('fujifilm_x_s10')).shift(); | ||
@@ -189,4 +264,55 @@ expect(item).to.have.own.property('preview'); | ||
it('leica cl preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('leica_cl')).shift(); | ||
expect(item).to.have.own.property('preview'); | ||
expect(item).to.have.own.property('source'); | ||
expect(path.dirname(item.source)).to.be.deep.equal(path.dirname(item.preview)); | ||
expect(path.basename(item.source, path.extname(item.source))).to.be.deep.equal(path.basename(item.preview, '.jpg')); | ||
expect(path.extname(item.preview)).to.deep.equal('.jpg'); | ||
await del(item.preview); | ||
}); | ||
it('leica v preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('leica_v')).shift(); | ||
expect(item).to.have.own.property('preview'); | ||
expect(item).to.have.own.property('source'); | ||
expect(path.dirname(item.source)).to.be.deep.equal(path.dirname(item.preview)); | ||
expect(path.basename(item.source, path.extname(item.source))).to.be.deep.equal(path.basename(item.preview, '.jpg')); | ||
expect(path.extname(item.preview)).to.deep.equal('.jpg'); | ||
await del(item.preview); | ||
}); | ||
it('sigma preview item in the array should contain objects with preview and source files', async () => { | ||
const item = done.filter(item => item.preview).filter(item => item.preview.includes('sigma')).shift(); | ||
expect(item).to.have.own.property('preview'); | ||
expect(item).to.have.own.property('source'); | ||
expect(path.dirname(item.source)).to.be.deep.equal(path.dirname(item.preview)); | ||
expect(path.basename(item.source, path.extname(item.source))).to.be.deep.equal(path.basename(item.preview, '.jpg')); | ||
expect(path.extname(item.preview)).to.deep.equal('.jpg'); | ||
await del(item.preview); | ||
}); | ||
}); | ||
}); |
@@ -19,8 +19,15 @@ const fs = require('fs'); | ||
`${samples}/nikon_d850_01.nef`, | ||
`${samples}/nikon_z7_ii_01.nef`, | ||
`${samples}/canon_eos_5d_mark_iv_01.cr2`, | ||
`${samples}/canon_eos_1d_x_mark_iii_01.cr3`, | ||
`${samples}/sony_a7r_iii_01.arw`, | ||
`${samples}/sony_a9_ii_01.arw`, | ||
`${samples}/panasonic_s1r_01.rw2`, | ||
`${samples}/panasonic_lumix_gh5_ii_01.rw2`, | ||
`${samples}/pentax_k_1_mark_ii_01.dng`, | ||
`${samples}/fujifilm_x_t3_01.raf`, | ||
`${samples}/fujifilm_x_s10_01.raf`, | ||
`${samples}/leica_cl_01.dng`, | ||
`${samples}/leica_v_lux_5_01.rwl`, | ||
`${samples}/sigma_sd1_merrill_01.x3f`, | ||
`${samples}/dummyFile.nef` | ||
@@ -47,3 +54,3 @@ ]; | ||
expect(done).to.have.lengthOf(7); | ||
expect(done).to.have.lengthOf(14); | ||
@@ -62,5 +69,5 @@ }); | ||
it('nikon preview should be returned in array', async () => { | ||
it('nikon d850 preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('nikon')).shift(); | ||
const item = done.filter(item => item.includes('nikon_d850')).shift(); | ||
@@ -75,5 +82,5 @@ expect(item).to.be.a('string'); | ||
it('canon preview should be returned in array', async () => { | ||
it('nikon z7 preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('canon')).shift(); | ||
const item = done.filter(item => item.includes('nikon_z7')).shift(); | ||
@@ -88,5 +95,5 @@ expect(item).to.be.a('string'); | ||
it('sony preview should be returned in array', async () => { | ||
it('canon eos 5d preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('sony')).shift(); | ||
const item = done.filter(item => item.includes('canon_eos_5d')).shift(); | ||
@@ -101,5 +108,5 @@ expect(item).to.be.a('string'); | ||
it('panasonic preview should be returned in array', async () => { | ||
it('canon eos 1d preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('panasonic')).shift(); | ||
const item = done.filter(item => item.includes('canon_eos_1d')).shift(); | ||
@@ -114,2 +121,50 @@ expect(item).to.be.a('string'); | ||
it('sony a7r preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('sony_a7r')).shift(); | ||
expect(item).to.be.a('string'); | ||
expect(path.extname(item)).to.deep.equal('.jpg'); | ||
await del(item); | ||
}); | ||
it('sony a9 preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('sony_a9')).shift(); | ||
expect(item).to.be.a('string'); | ||
expect(path.extname(item)).to.deep.equal('.jpg'); | ||
await del(item); | ||
}); | ||
it('panasonic s1r preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('panasonic_s1r')).shift(); | ||
expect(item).to.be.a('string'); | ||
expect(path.extname(item)).to.deep.equal('.jpg'); | ||
await del(item); | ||
}); | ||
it('panasonic lumix preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('panasonic_lumix')).shift(); | ||
expect(item).to.be.a('string'); | ||
expect(path.extname(item)).to.deep.equal('.jpg'); | ||
await del(item); | ||
}); | ||
it('pentax preview should be returned in array', async () => { | ||
@@ -127,5 +182,5 @@ | ||
it('fujifilm preview should be returned in array', async () => { | ||
it('fujifilm x t3 preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('fujifilm')).shift(); | ||
const item = done.filter(item => item.includes('fujifilm_x_t3')).shift(); | ||
@@ -140,5 +195,5 @@ expect(item).to.be.a('string'); | ||
it('leica preview should be returned in array', async () => { | ||
it('fujifilm x s10 preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('leica')).shift(); | ||
const item = done.filter(item => item.includes('fujifilm_x_s10')).shift(); | ||
@@ -153,4 +208,40 @@ expect(item).to.be.a('string'); | ||
it('leica cl preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('leica_cl')).shift(); | ||
expect(item).to.be.a('string'); | ||
expect(path.extname(item)).to.deep.equal('.jpg'); | ||
await del(item); | ||
}); | ||
it('leica v preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('leica_v')).shift(); | ||
expect(item).to.be.a('string'); | ||
expect(path.extname(item)).to.deep.equal('.jpg'); | ||
await del(item); | ||
}); | ||
it('sigma preview should be returned in array', async () => { | ||
const item = done.filter(item => item.includes('sigma')).shift(); | ||
expect(item).to.be.a('string'); | ||
expect(path.extname(item)).to.deep.equal('.jpg'); | ||
await del(item); | ||
}); | ||
}); | ||
}); |
@@ -9,2 +9,3 @@ const fs = require('fs'); | ||
const del = util.promisify(fs.unlink); | ||
const read = util.promisify(fs.readFile); | ||
const pipeline = util.promisify(stream.pipeline); | ||
@@ -155,2 +156,196 @@ | ||
context('with existing file and base64 outcome', () => { | ||
let done = {}; | ||
const source = `${samples}/nikon_d850_01.nef`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
base64: true, | ||
persist: true | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('should indicate persistent status with ability to join', () => { | ||
const status = extractd.status(); | ||
expect(status.persistent).to.be.true; | ||
}); | ||
it('should indicate desist status', async () => { | ||
const status = await extractd.desist(); | ||
expect(status.persistent).to.be.false; | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('should be base64 jpg encoded string', async () => { | ||
const id = done.preview.substring(0, 4); | ||
expect(id).to.be.deep.equal('/9j/'); | ||
}); | ||
}); | ||
context('with existing file orientation change and base64 outcome', () => { | ||
let done = {}; | ||
const source = `${samples}/fujifilm_x_t3_01.raf`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
base64: true, | ||
persist: true | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('should indicate persistent status with ability to join', () => { | ||
const status = extractd.status(); | ||
expect(status.persistent).to.be.true; | ||
}); | ||
it('should indicate desist status', async () => { | ||
const status = await extractd.desist(); | ||
expect(status.persistent).to.be.false; | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('should be base64 jpg encoded string', async () => { | ||
const id = done.preview.substring(0, 4); | ||
expect(id).to.be.deep.equal('/9j/'); | ||
}); | ||
}); | ||
context('with existing file and base64 datauri outcome', () => { | ||
let done = {}; | ||
const source = `${samples}/nikon_d850_01.nef`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
base64: true, | ||
datauri: true, | ||
persist: true | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('should indicate persistent status with ability to join', () => { | ||
const status = extractd.status(); | ||
expect(status.persistent).to.be.true; | ||
}); | ||
it('should indicate desist status', async () => { | ||
const status = await extractd.desist(); | ||
expect(status.persistent).to.be.false; | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('should be base64 datauri jpg encoded string', async () => { | ||
const id = done.preview.substring(0, 27); | ||
expect(id).to.be.deep.equal('data:image/jpeg;base64,/9j/'); | ||
}); | ||
}); | ||
context('with existing file orientation change and base64 datauri outcome', () => { | ||
let done = {}; | ||
const source = `${samples}/fujifilm_x_t3_01.raf`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
base64: true, | ||
datauri: true, | ||
persist: true | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('should indicate persistent status with ability to join', () => { | ||
const status = extractd.status(); | ||
expect(status.persistent).to.be.true; | ||
}); | ||
it('should indicate desist status', async () => { | ||
const status = await extractd.desist(); | ||
expect(status.persistent).to.be.false; | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('should be base64 datauri jpg encoded string', async () => { | ||
const id = done.preview.substring(0, 27); | ||
expect(id).to.be.deep.equal('data:image/jpeg;base64,/9j/'); | ||
}); | ||
}); | ||
context('with existing file and set destination outcome as a stream', () => { | ||
@@ -221,3 +416,252 @@ | ||
context('with existing file and set destination outcome as a base64 stream', () => { | ||
let done = {}; | ||
const source = `${samples}/nikon_d850_01.nef`; | ||
const pipedFile = `${samples}/myNewBase64PipedFile.txt`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
stream: true, | ||
base64: true, | ||
persist: true, | ||
destination: samples | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('preview should be accessible as a stream', () => { | ||
expect(typeof done.preview.on === 'function').to.be.true; | ||
}); | ||
it('preview can be piped in to a file stream', async () => { | ||
await pipeline(done.preview, fs.createWriteStream(pipedFile)); | ||
expect(path.dirname(done.source)).to.be.deep.equal(path.dirname(pipedFile)); | ||
}); | ||
it('should generate preview file', async () => { | ||
const preview = path.basename(pipedFile); | ||
expect(preview).to.be.deep.equal(path.basename(pipedFile)); | ||
}); | ||
it('should be base64 jpg encoded file', async () => { | ||
const content = (await read(pipedFile)).toString(); | ||
const id = content.substring(0, 4); | ||
expect(id).to.be.deep.equal('/9j/'); | ||
await del(pipedFile); | ||
}); | ||
}); | ||
context('with existing file orientation change and set destination outcome as a base64 stream', () => { | ||
let done = {}; | ||
const source = `${samples}/fujifilm_x_t3_01.raf`; | ||
const pipedFile = `${samples}/myNewBase64PipedFile.txt`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
stream: true, | ||
base64: true, | ||
persist: true, | ||
destination: samples | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('preview should be accessible as a stream', () => { | ||
expect(typeof done.preview.on === 'function').to.be.true; | ||
}); | ||
it('preview can be piped in to a file stream', async () => { | ||
await pipeline(done.preview, fs.createWriteStream(pipedFile)); | ||
expect(path.dirname(done.source)).to.be.deep.equal(path.dirname(pipedFile)); | ||
}); | ||
it('should generate preview file', async () => { | ||
const preview = path.basename(pipedFile); | ||
expect(preview).to.be.deep.equal(path.basename(pipedFile)); | ||
}); | ||
it('should be base64 jpg encoded file', async () => { | ||
const content = (await read(pipedFile)).toString(); | ||
const id = content.substring(0, 4); | ||
expect(id).to.be.deep.equal('/9j/'); | ||
await del(pipedFile); | ||
}); | ||
}); | ||
context('with existing file and set destination outcome as a base64 datauri stream', () => { | ||
let done = {}; | ||
const source = `${samples}/nikon_d850_01.nef`; | ||
const pipedFile = `${samples}/myNewBase64URIPipedFile.txt`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
stream: true, | ||
base64: true, | ||
datauri: true, | ||
persist: true, | ||
destination: samples | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('preview should be accessible as a stream', () => { | ||
expect(typeof done.preview.on === 'function').to.be.true; | ||
}); | ||
it('preview can be piped in to a file stream', async () => { | ||
await pipeline(done.preview, fs.createWriteStream(pipedFile)); | ||
expect(path.dirname(done.source)).to.be.deep.equal(path.dirname(pipedFile)); | ||
}); | ||
it('should generate preview file', async () => { | ||
const preview = path.basename(pipedFile); | ||
expect(preview).to.be.deep.equal(path.basename(pipedFile)); | ||
}); | ||
it('should be base64 datauri jpg encoded file', async () => { | ||
const content = (await read(pipedFile)).toString(); | ||
const id = content.substring(0, 27); | ||
expect(id).to.be.deep.equal('data:image/jpeg;base64,/9j/'); | ||
await del(pipedFile); | ||
}); | ||
}); | ||
context('with existing file and set destination outcome as a base64 datauri stream', () => { | ||
let done = {}; | ||
const source = `${samples}/fujifilm_x_t3_01.raf`; | ||
const pipedFile = `${samples}/myNewBase64URIPipedFile.txt`; | ||
it('should return an object', async () => { | ||
done = await extractd.generate(source, { | ||
stream: true, | ||
base64: true, | ||
datauri: true, | ||
persist: true, | ||
destination: samples | ||
}); | ||
expect(done).to.be.an('object'); | ||
}); | ||
it('object should contain preview and original source', () => { | ||
expect(done).to.have.own.property('preview'); | ||
expect(done).to.have.own.property('source'); | ||
}); | ||
it('preview should be accessible as a stream', () => { | ||
expect(typeof done.preview.on === 'function').to.be.true; | ||
}); | ||
it('preview can be piped in to a file stream', async () => { | ||
await pipeline(done.preview, fs.createWriteStream(pipedFile)); | ||
expect(path.dirname(done.source)).to.be.deep.equal(path.dirname(pipedFile)); | ||
}); | ||
it('should generate preview file', async () => { | ||
const preview = path.basename(pipedFile); | ||
expect(preview).to.be.deep.equal(path.basename(pipedFile)); | ||
}); | ||
it('should be base64 datauri jpg encoded file', async () => { | ||
const content = (await read(pipedFile)).toString(); | ||
const id = content.substring(0, 27); | ||
expect(id).to.be.deep.equal('data:image/jpeg;base64,/9j/'); | ||
await del(pipedFile); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56078
16
995
348
4
6
+ Addedbase64-stream@^1.0.0
+ Added@types/luxon@2.4.0(transitive)
+ Addedbase64-stream@1.0.0(transitive)
+ Addedbatch-cluster@10.4.3(transitive)
+ Addedexiftool-vendored@15.12.1(transitive)
+ Addedexiftool-vendored.exe@12.40.0(transitive)
+ Addedexiftool-vendored.pl@12.40.0(transitive)
+ Addedluxon@2.5.2(transitive)
- Removedbatch-cluster@6.2.1(transitive)
- Removedexiftool-vendored@14.6.2(transitive)
- Removedexiftool-vendored.exe@12.97.0(transitive)
- Removedexiftool-vendored.pl@12.97.0(transitive)
- Removedluxon@1.28.1(transitive)
Updatedexiftool-vendored@^15.1.0