From f5d2ec0ce24d8e4977361ff279fc7fe349fcdc43 Mon Sep 17 00:00:00 2001 From: Onildo Aguiar Date: Sat, 6 Jun 2020 21:55:29 -0400 Subject: [PATCH] fix: forced dimensions * fix: forced dimensions * feat: update version --- .github/workflows/npmpublish.yml | 14 ----- package.json | 2 +- src/index.js | 33 +++--------- src/util.js | 5 ++ test/_fixtures/thumbnailBase64FromBase64.json | 2 +- .../thumbnailBase64FromFilePath.json | 2 +- test/_fixtures/thumbnailBase64FromUri.json | 2 +- test/_fixtures/thumbnailBufferFromBase64.json | 2 +- .../thumbnailBufferFromFilePath.json | 2 +- test/_fixtures/thumbnailBufferFromUri.json | 2 +- test/imageThumbnail.test.js | 53 +++++++++++++++---- 11 files changed, 60 insertions(+), 59 deletions(-) diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index 861e372..be9461b 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -31,17 +31,3 @@ jobs: - run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - publish-gpr: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12 - registry-url: https://npm.pkg.github.com/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/package.json b/package.json index ca3b1eb..6b5f801 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "image-thumbnail", - "version": "1.0.8", + "version": "1.0.9", "description": "Generate an image thumbnail.", "main": "index.js", "scripts": { diff --git a/src/index.js b/src/index.js index c189d06..b80c430 100644 --- a/src/index.js +++ b/src/index.js @@ -110,12 +110,8 @@ module.exports = async (source, options) => { }; const getDimensions = (imageBuffer, percentageOfImage, dimensions) => { - if (typeof dimensions.width != 'undefined' && typeof dimensions.height != 'undefined') { - return { width: dimensions.width, height: dimensions.height }; - } - if (typeof dimensions.width != 'undefined' || typeof dimensions.height != 'undefined') { - return mergeDimensions(imageBuffer, dimensions) + return util.removeUndefined(dimensions); } const originalDimensions = sizeOf(imageBuffer); @@ -126,36 +122,19 @@ const getDimensions = (imageBuffer, percentageOfImage, dimensions) => { return { width, height }; } -const mergeDimensions = (imageBuffer, dimensions) => { - const originalDimensions = sizeOf(imageBuffer); - let newDimensions = dimensions - - if (typeof dimensions.width == 'undefined') - newDimensions = { width: originalDimensions.width, height: dimensions.height }; - else if (typeof dimensions.height == 'undefined') - newDimensions = { width: dimensions.width, height: originalDimensions.height }; - - return newDimensions; -} - const sharpResize = (imageBuffer, dimensions, jpegOptions) => { return new Promise((resolve, reject) => { sharp(imageBuffer) - .resize({ width: dimensions.width, height: dimensions.height, withoutEnlargement: true }) + .resize({ + ...dimensions, withoutEnlargement: true, fit: 'contain', + }) .jpeg(jpegOptions ? jpegOptions : { force: false }) - .toBuffer((err, data, info) => { + .toBuffer((err, data) => { if (err) { reject(err); } else { - const { format, width, height, size } = info; - const imagePayload = { - format: format, - width: width, - height: height, - size: size, - }; resolve(data); } }); }); -}; +}; \ No newline at end of file diff --git a/src/util.js b/src/util.js index 7d2bc21..7f52698 100644 --- a/src/util.js +++ b/src/util.js @@ -9,4 +9,9 @@ module.exports.streamToBuffer = (stream) => { resolve(Buffer.concat(buffers)); }) }) +} + +module.exports.removeUndefined = (dimensions) => { + Object.keys(dimensions).forEach(key => dimensions[key] === undefined && delete dimensions[key]); + return dimensions } \ No newline at end of file diff --git a/test/_fixtures/thumbnailBase64FromBase64.json b/test/_fixtures/thumbnailBase64FromBase64.json index 05260d2..525d8a9 100644 --- a/test/_fixtures/thumbnailBase64FromBase64.json +++ b/test/_fixtures/thumbnailBase64FromBase64.json @@ -1,3 +1,3 @@ { - "base64": "/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAGAAoDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAYH/8QAHhAAAgICAgMAAAAAAAAAAAAAAQIAEQMEBhITIaH/xAAVAQEBAAAAAAAAAAAAAAAAAAADBP/EABsRAAIBBQAAAAAAAAAAAAAAAAABAgMEESFh/9oADAMBAAIRAxEAPwCV5Xj29TgmAhsJXaLphAsePqhc2KIa+rfJgDEsxZjZPskxEntklDI9bSiuH//Z" + "base64": "/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAGAAoDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAYH/8QAHhAAAgICAgMAAAAAAAAAAAAAAQIAEQMEBiESExT/xAAUAQEAAAAAAAAAAAAAAAAAAAAD/8QAGxEAAQQDAAAAAAAAAAAAAAAAAAECAxEEIXH/2gAMAwEAAhEDEQA/AIPn+r8vDNPM2tptnyo/oy+ALIiAEgki77NUa6ExGIgY6UwaXVcP/9k=" } \ No newline at end of file diff --git a/test/_fixtures/thumbnailBase64FromFilePath.json b/test/_fixtures/thumbnailBase64FromFilePath.json index f44580a..b40ed21 100644 --- a/test/_fixtures/thumbnailBase64FromFilePath.json +++ b/test/_fixtures/thumbnailBase64FromFilePath.json @@ -1,3 +1,3 @@ { - "base64": "/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo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FDbLnMCXkKHMIThIJBOMZPbvV9J05C5CKSvX4LFFOj2PBnPMaYxdbfdpEm9PNLKUhppptSkyFcWeFR/twN968/wAOkuG0lEuNMkSQtLLDiweVuU5cBwE53IJPQZqneLjqPQarlpGSzHSObxrSpsOgkge5Cu4IArF0jBnXfUMaEpbrYkL4eJwEIBPx/wACiejYZAy+h+XRrpVpj6Lda/2DtxjKiylNqG3UEdCPNVa6S1N/TsJER2RZdSMOzmmwpTL7QQ2r4Cwo46Hsa54u1vkWq5SYM1ARIjrLawDkZHg9xVCNcCY1YL6jYdX1KlSpUo4qf//Z" } \ No newline at end of file diff --git a/test/_fixtures/thumbnailBase64FromUri.json b/test/_fixtures/thumbnailBase64FromUri.json index 9f0baaf..c45f3c1 100644 --- a/test/_fixtures/thumbnailBase64FromUri.json +++ b/test/_fixtures/thumbnailBase64FromUri.json @@ -1,3 +1,3 @@ { - "base64": "/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABAAGADASIAAhEBAxEB/8QAHAAAAgIDAQEAAAAAAAAAAAAABQcEBgADCAEC/8QANBAAAQMDAwIEBQIFBQAAAAAAAQIDBAAFEQYSITFBBxMiURQyYXGBFZEIUqGx0SMzQkPB/8QAGQEAAwEBAQAAAAAAAAAAAAAAAgMEBQAB/8QAJhEAAgEEAgEDBQEAAAAAAAAAAQIAAxESIQQxQRMiUQUjcYHh8P/aAAwDAQACEQMRAD8AVhTdn4F4YiLZXAac2OOIGNwB4IqPabLJWgypDaRFCSQT3oat2fbd8dSltjAK0fzGrVqdq8ItNs+KQ202+gKSlpXy596y3uNC1jOGupconhC5Pt0SbJmMsxlIDiUp5JBGRzQK++EExhC5MByPMZz/ANZ2rH4P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uxeJNyTZBIfimelxUQFxC8qSCdqsHIOPtil5qDQadOX1K23lSnirAjoAPlnHJPPv0HY1uaOt8XSOpF3eLHU5MSVIZ82QFIaB44OBg4OOeaYku6Wi1WeReL4+zImOJOGwR6c5wBntVDU1Qfj1EiqzEB9zlrUVvNiu5Wy8+1JQsOJQ42ElPfqCRWJKluS1Fb/qc/m7miXXV7t95e3xo4Q+lZPmJPCknsR8UI1VSBxBbuIdtkDqSpUqU2LjfYDKYEwXNShNJHlBPQJrS1De3b1a7dEKGg1GQEpUhOCod609A6GOsm5yjMDDMZB3KJ5J9qpOOTZcmFDtdvYW7DV5KO27BxuI9u9ZOsvup0KToe89XyhAhNsx0NLUkFtKucA/qNZ11aE28RmnJjMWO48iMFuEJSVEgFZJ6AZ5PTApiXjR0x5tFwhuMJkYAcbWSlI+U/wDFFFp03p5FnaSLZBnPITuU4+yFKUTyTzk0kVlom5mmnFOOIk8SPCzQ0LQkq7x2XYa7bCLyJkNz1SFJHpKgcpWVKx6h79aVD8C56Ts0HUV/j26WgtIxkKKwXE8BaONxHuD2p2x2dH3KxrsVxiOW+3vkb0x3VstKUDkZAOByAenNZ3il4eP6ytEWDZr1BQ2y75gS8gjzCE4SCQTjGT271fSdOQoYRSV6/BYop0ex7Gc8xpjF1t92kSb080vakNNNNqUmQrdnao/pwOa8zbpDhtJRMjTZEkLSyw4sHyuSnLgOAnPJBJ6DNU7xcdR6DVctIyWY6R5u9aVNh0EkD1IV3BAH/VYukYM676hjQlLdb/EL27nAQgE/H+wono2GSmX0PF0a6VaY+i3X9g7cYyostbahx1BHQj3qrXSWpv4dhIiOybLqRh2c02FKZfaCG1fAWFHHQ9jXPF2t8i1XKTBmoCJEdZbWAcjI9j3FUI1wJjVgvmNh1fUqVKlSjip//9k=" } \ No newline at end of file diff --git a/test/_fixtures/thumbnailBufferFromBase64.json b/test/_fixtures/thumbnailBufferFromBase64.json index 616b4fa..b762130 100644 --- a/test/_fixtures/thumbnailBufferFromBase64.json +++ b/test/_fixtures/thumbnailBufferFromBase64.json @@ -1,3 +1,3 @@ { - "buffer": {"type":"Buffer","data":[255,216,255,219,0,67,0,6,4,5,6,5,4,6,6,5,6,7,7,6,8,10,16,10,10,9,9,10,20,14,15,12,16,23,20,24,24,23,20,22,22,26,29,37,31,26,27,35,28,22,22,32,44,32,35,38,39,41,42,41,25,31,45,48,45,40,48,37,40,41,40,255,219,0,67,1,7,7,7,10,8,10,19,10,10,19,40,26,22,26,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,255,192,0,17,8,0,6,0,10,3,1,34,0,2,17,1,3,17,1,255,196,0,22,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,255,196,0,30,16,0,2,2,2,2,3,0,0,0,0,0,0,0,0,0,0,1,2,0,17,3,4,6,18,19,33,161,255,196,0,21,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,4,255,196,0,27,17,0,2,1,5,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,17,33,97,255,218,0,12,3,1,0,2,17,3,17,0,63,0,149,229,120,246,245,56,38,2,27,9,93,162,233,132,11,30,62,168,92,216,162,26,250,183,201,128,49,44,197,152,217,62,201,49,18,123,100,148,50,61,109,40,174,31,255,217]} + "buffer": {"type":"Buffer","data":[255,216,255,219,0,67,0,6,4,5,6,5,4,6,6,5,6,7,7,6,8,10,16,10,10,9,9,10,20,14,15,12,16,23,20,24,24,23,20,22,22,26,29,37,31,26,27,35,28,22,22,32,44,32,35,38,39,41,42,41,25,31,45,48,45,40,48,37,40,41,40,255,219,0,67,1,7,7,7,10,8,10,19,10,10,19,40,26,22,26,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,255,192,0,17,8,0,6,0,10,3,1,34,0,2,17,1,3,17,1,255,196,0,22,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,255,196,0,30,16,0,2,2,2,2,3,0,0,0,0,0,0,0,0,0,0,1,2,0,17,3,4,6,33,18,19,20,255,196,0,20,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,255,196,0,27,17,0,1,4,3,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,17,4,33,113,255,218,0,12,3,1,0,2,17,3,17,0,63,0,131,231,250,191,47,12,211,204,218,218,109,159,42,63,163,47,128,44,136,128,18,9,34,239,179,84,107,161,49,24,136,24,233,76,26,93,87,15,255,217]} } \ No newline at end of file diff --git a/test/_fixtures/thumbnailBufferFromFilePath.json b/test/_fixtures/thumbnailBufferFromFilePath.json index 52f34a6..61b1622 100644 --- a/test/_fixtures/thumbnailBufferFromFilePath.json +++ b/test/_fixtures/thumbnailBufferFromFilePath.json @@ -1,3 +1,3 @@ { - "buffer": {"type":"Buffer","data":[255,216,255,219,0,67,0,6,4,5,6,5,4,6,6,5,6,7,7,6,8,10,16,10,10,9,9,10,20,14,15,12,16,23,20,24,24,23,20,22,22,26,29,37,31,26,27,35,28,22,22,32,44,32,35,38,39,41,42,41,25,31,45,48,45,40,48,37,40,41,40,255,219,0,67,1,7,7,7,10,8,10,19,10,10,19,40,26,22,26,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,255,192,0,17,8,0,64,0,96,3,1,34,0,2,17,1,3,17,1,255,196,0,28,0,0,2,2,3,1,1,0,0,0,0,0,0,0,0,0,0,5,6,4,7,0,3,8,1,2,255,196,0,52,16,0,1,3,3,2,4,5,2,4,6,3,0,0,0,0,0,1,2,3,4,0,5,17,6,33,18,19,49,65,7,20,34,81,97,113,129,21,50,82,145,8,35,51,161,177,193,66,67,209,255,196,0,25,1,0,3,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,3,4,5,0,1,255,196,0,38,17,0,2,2,1,4,1,3,5,1,0,0,0,0,0,0,0,1,2,0,17,3,4,18,33,49,81,19,34,65,5,35,113,129,225,240,255,218,0,12,3,1,0,2,17,3,17,0,63,0,170,212,155,179,246,251,195,17,22,202,224,52,231,3,142,32,99,139,7,98,42,61,166,203,37,104,50,164,54,4,80,156,130,123,208,245,187,62,219,199,29,74,82,6,1,90,63,81,250,83,78,168,106,240,139,69,179,205,33,182,154,125,1,65,45,43,100,231,222,178,222,199,2,168,206,28,117,28,162,120,66,228,251,116,73,178,37,178,204,101,32,56,148,167,36,144,70,70,244,10,251,225,4,198,18,185,48,28,143,49,144,127,235,60,43,31,99,177,253,234,196,240,171,81,187,112,211,146,116,229,204,133,204,136,198,88,88,31,212,64,237,245,165,216,250,133,203,109,225,81,144,225,44,56,172,22,214,113,246,20,54,84,88,50,161,141,94,133,74,11,84,216,110,22,183,215,231,99,41,160,147,140,227,0,230,151,107,170,111,122,121,173,82,201,132,225,88,67,199,9,36,110,131,85,149,171,193,43,171,178,93,69,214,107,49,18,131,128,150,135,53,68,118,207,64,42,140,58,212,43,239,226,167,62,145,148,210,115,42,58,202,184,39,120,58,134,74,155,102,228,234,157,198,220,109,0,63,205,38,222,116,5,234,211,41,134,228,50,22,203,174,37,176,235,103,32,18,113,184,234,41,235,169,196,253,24,13,166,200,189,136,164,1,61,5,121,86,36,125,55,29,15,114,155,103,152,51,142,34,123,14,255,0,21,14,100,75,64,185,38,60,40,137,112,3,133,168,171,169,239,244,161,93,74,185,165,156,218,118,81,204,71,172,171,15,85,105,59,109,187,78,139,145,120,70,125,123,54,199,22,74,254,213,94,83,145,195,139,17,76,165,123,151,117,153,196,220,17,45,185,22,179,46,95,2,148,22,55,35,230,135,200,149,52,71,99,206,5,172,15,75,65,125,54,237,138,63,224,77,194,26,53,172,152,215,137,137,138,195,204,171,132,172,227,36,118,6,162,95,165,70,141,172,148,136,175,174,101,189,135,213,194,165,15,204,156,255,0,154,204,42,67,17,81,102,251,159,90,114,242,229,178,251,18,82,27,12,56,156,37,67,135,243,125,71,122,179,110,246,43,101,236,166,100,21,198,91,143,225,78,54,224,80,40,61,246,199,74,143,102,135,167,231,184,220,187,162,210,134,207,174,32,65,220,156,116,52,102,30,162,131,165,145,61,201,110,230,34,19,148,199,101,3,42,87,215,169,63,61,169,59,207,137,86,159,33,34,140,208,234,27,211,22,50,164,60,151,31,95,165,24,206,71,239,185,162,186,93,137,168,177,187,54,68,114,94,81,37,92,99,10,25,239,131,85,101,243,85,93,245,28,185,87,43,76,39,161,195,136,218,158,101,110,53,197,235,3,110,187,31,124,84,61,1,174,111,242,36,169,185,10,151,49,114,89,229,56,167,223,14,18,191,212,8,0,0,127,78,228,98,188,244,73,12,254,37,227,37,82,121,142,111,205,91,215,119,1,72,230,37,71,41,161,218,242,239,248,83,17,157,229,148,58,133,5,112,44,117,161,50,83,114,211,87,53,93,174,105,82,152,67,132,165,32,100,171,211,182,126,244,163,122,241,5,87,246,164,64,184,198,106,107,146,80,178,149,4,20,59,13,193,249,112,174,138,30,227,31,189,6,159,3,61,176,232,70,231,202,16,128,96,237,83,120,67,241,10,237,81,223,105,78,228,173,92,28,88,63,24,219,247,160,58,122,209,40,63,230,229,44,166,50,61,110,175,168,2,155,244,4,198,175,108,166,0,146,152,210,27,30,191,89,74,200,29,211,239,143,106,23,226,61,231,146,13,158,28,244,60,195,100,229,214,219,9,42,62,203,199,95,131,189,104,99,27,79,166,163,153,14,67,126,230,138,90,190,252,237,242,229,196,79,12,86,7,45,134,199,68,164,127,179,64,107,211,214,188,171,149,66,138,18,38,54,110,93,26,207,74,203,181,235,103,218,185,52,204,121,170,87,59,148,218,178,129,157,246,62,212,199,225,116,155,123,215,139,156,75,205,161,203,148,130,222,99,161,148,5,144,161,238,62,118,161,90,223,83,166,247,172,81,121,242,197,206,96,74,93,74,246,24,27,3,95,22,219,163,154,94,250,229,202,222,165,34,67,232,41,73,8,33,56,61,183,172,178,88,138,48,71,13,127,18,77,213,155,180,171,131,178,216,134,168,105,138,232,79,148,7,10,73,247,0,109,91,47,109,54,235,41,126,116,150,83,130,50,203,217,43,82,189,184,71,79,190,42,3,151,169,247,25,74,112,60,177,37,106,207,16,219,38,129,222,38,220,228,190,150,167,62,234,219,128,176,134,210,84,84,1,198,78,0,234,70,219,156,209,225,93,198,143,196,37,187,177,45,223,15,162,121,219,115,240,158,99,240,247,21,235,66,14,201,88,236,112,78,217,166,232,26,95,79,105,251,28,203,244,246,30,102,21,177,181,60,182,154,25,42,87,93,177,219,255,0,106,158,211,58,168,60,194,100,185,33,168,203,99,96,156,149,45,99,228,124,211,195,154,184,56,204,203,57,113,11,76,180,20,185,21,193,158,18,70,251,143,124,244,237,64,184,151,121,14,38,141,229,41,187,28,133,103,185,217,124,76,152,187,49,121,214,36,200,97,199,226,164,58,149,130,83,185,10,199,67,211,251,213,125,122,208,205,88,47,196,69,113,201,110,172,148,242,145,140,50,49,191,93,179,185,20,193,161,226,179,163,175,15,92,96,177,199,53,192,166,146,227,210,56,144,218,73,232,14,6,54,251,211,213,214,243,101,176,88,95,184,93,36,53,42,123,201,199,8,41,200,39,182,251,226,158,216,213,71,219,226,36,100,118,35,127,51,151,111,208,255,0,3,187,168,199,117,230,228,54,190,32,149,164,2,159,184,36,80,89,18,87,35,212,238,235,233,197,220,211,6,181,188,194,188,62,135,35,71,13,188,146,120,150,158,139,29,179,243,75,21,94,49,237,5,187,147,57,228,215,83,43,43,43,41,144,37,190,223,151,69,182,66,103,169,66,225,204,28,56,232,17,68,245,45,233,235,243,112,27,117,13,242,163,161,41,79,45,56,42,2,138,232,141,4,117,125,174,225,49,82,195,44,70,65,220,157,212,71,106,132,219,243,174,87,56,13,219,32,49,204,99,13,12,244,194,118,42,35,218,178,120,221,254,226,122,170,199,129,54,200,41,76,152,172,178,194,25,89,72,41,73,223,129,62,255,0,90,28,236,102,174,154,150,12,121,83,218,135,18,76,132,199,11,112,132,128,50,2,150,79,108,127,161,86,13,227,70,75,82,147,112,132,235,41,42,192,117,43,56,225,29,202,113,215,233,77,112,116,238,158,106,210,208,69,170,12,181,52,141,220,121,144,165,31,114,115,189,36,102,92,38,204,211,93,41,219,181,100,127,23,124,53,209,86,221,15,54,253,111,138,236,9,16,99,37,81,221,134,188,115,220,217,40,10,73,217,89,36,122,135,201,222,170,251,172,59,150,137,129,30,241,124,106,221,36,186,132,178,149,240,40,168,41,105,200,42,71,117,39,29,65,171,177,184,250,58,241,105,110,205,113,140,228,24,138,90,92,66,26,113,77,180,92,73,200,60,61,54,246,161,62,44,120,107,51,90,196,138,205,166,239,13,40,140,165,184,16,243,106,28,197,17,141,200,39,24,21,161,141,147,80,161,196,82,106,51,232,152,160,60,30,193,232,206,123,106,68,123,141,150,227,34,69,226,66,95,43,64,101,150,219,37,183,142,119,42,63,241,32,31,239,95,14,219,100,56,228,4,162,100,89,114,100,199,95,10,22,177,252,132,144,115,197,156,4,171,25,52,58,243,122,212,26,65,153,218,66,91,76,54,150,94,81,90,22,216,89,10,56,221,42,232,65,192,57,197,65,208,86,185,151,237,73,26,222,93,113,1,243,142,39,50,82,55,246,239,215,167,205,122,248,118,141,202,102,134,31,171,163,218,101,198,63,63,175,31,216,169,53,133,71,146,182,212,49,208,143,161,25,21,162,186,63,85,255,0,14,229,200,146,38,88,53,11,82,36,180,144,84,204,134,194,16,163,142,129,96,156,125,197,115,188,232,175,65,154,252,89,41,224,121,149,150,214,159,98,14,13,82,141,98,98,101,11,188,237,234,230,138,202,202,202,40,185,255,217]} + "buffer": {"type":"Buffer","data":[255,216,255,219,0,67,0,6,4,5,6,5,4,6,6,5,6,7,7,6,8,10,16,10,10,9,9,10,20,14,15,12,16,23,20,24,24,23,20,22,22,26,29,37,31,26,27,35,28,22,22,32,44,32,35,38,39,41,42,41,25,31,45,48,45,40,48,37,40,41,40,255,219,0,67,1,7,7,7,10,8,10,19,10,10,19,40,26,22,26,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,255,192,0,17,8,0,64,0,96,3,1,34,0,2,17,1,3,17,1,255,196,0,28,0,0,2,3,1,1,1,1,0,0,0,0,0,0,0,0,0,6,7,0,4,5,8,3,1,2,255,196,0,51,16,0,1,3,3,2,5,3,2,5,3,5,0,0,0,0,0,1,2,3,4,0,5,17,6,33,18,19,49,65,81,7,34,97,20,50,21,113,129,145,177,8,66,82,114,130,193,209,240,255,196,0,25,1,0,3,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,3,4,5,1,0,255,196,0,37,17,0,2,1,4,2,1,4,3,1,0,0,0,0,0,0,0,1,2,0,3,17,18,33,4,49,65,19,34,81,240,5,35,50,177,255,218,0,12,3,1,0,2,17,3,17,0,63,0,87,184,155,179,127,142,219,224,183,25,216,236,146,219,207,180,54,32,19,184,172,235,69,162,84,133,115,156,103,49,146,14,86,123,213,68,201,184,219,18,227,42,82,154,230,36,41,212,244,226,162,139,218,174,237,233,155,107,139,142,152,241,228,32,20,134,206,248,249,252,250,214,91,93,127,155,110,120,106,19,91,253,37,153,118,181,196,153,206,98,60,53,142,98,125,217,42,73,233,89,55,239,71,238,49,66,228,67,12,76,96,117,44,175,222,63,218,122,254,244,200,244,123,81,187,42,196,238,153,186,0,101,48,193,84,101,143,239,64,223,31,157,98,13,66,229,174,240,184,232,113,74,97,106,225,83,107,56,199,192,205,8,98,162,224,202,133,53,123,9,207,122,154,201,58,220,242,196,168,170,100,32,245,41,32,16,122,26,31,174,168,191,89,26,212,172,24,139,42,8,124,240,164,168,110,130,105,85,7,209,123,235,179,223,102,123,204,66,105,10,33,42,39,152,165,12,144,15,8,232,15,201,170,40,243,17,151,223,171,78,63,17,148,217,55,21,149,41,179,59,209,215,163,146,132,93,2,221,236,11,24,31,205,7,95,116,61,238,204,180,253,76,110,54,84,160,128,235,103,41,201,56,25,241,79,78,77,39,208,48,27,143,81,54,68,24,0,158,149,242,143,218,210,236,178,247,36,52,167,150,15,9,35,200,235,85,238,86,219,60,121,200,141,29,133,58,224,56,112,241,237,158,248,174,47,37,24,217,103,79,29,148,92,192,138,148,195,190,232,216,49,116,226,238,188,225,19,3,216,218,213,146,225,248,20,188,166,163,135,234,41,148,175,113,219,104,117,139,147,239,162,125,181,114,228,169,42,40,41,235,241,181,80,145,54,97,132,202,38,7,20,194,15,11,73,94,192,99,181,108,122,39,58,56,245,13,44,93,37,162,43,15,54,164,133,56,64,201,3,160,61,5,126,181,155,209,162,235,55,99,67,149,245,208,89,144,162,20,64,194,134,199,25,31,168,172,194,164,57,22,139,55,238,86,177,94,21,110,188,195,152,211,105,97,228,28,40,227,238,252,233,161,122,178,91,47,168,69,194,34,226,173,231,192,43,105,74,225,41,87,114,62,42,173,154,221,167,238,174,181,46,230,180,179,15,101,199,82,72,10,42,25,216,248,223,181,111,219,175,16,116,211,243,28,148,234,19,9,13,241,114,208,216,82,214,175,245,117,39,227,160,164,230,126,37,60,106,132,232,202,236,71,70,153,178,45,242,250,28,115,28,45,251,137,225,253,123,255,0,237,234,254,145,76,183,173,146,46,50,24,83,142,40,147,149,108,113,231,6,150,250,131,87,205,213,23,39,30,178,64,125,168,17,144,94,11,144,201,80,82,210,9,0,246,35,190,59,226,179,116,39,168,186,129,235,130,126,185,217,147,156,125,162,219,188,215,16,114,163,156,20,4,164,112,167,160,225,57,61,193,237,92,244,75,93,250,180,188,84,181,151,230,26,207,156,167,174,238,36,164,5,131,246,138,161,174,46,104,183,219,152,116,183,135,18,160,174,5,167,101,126,253,171,30,99,119,59,61,227,241,91,162,79,209,161,196,146,48,73,80,199,241,156,80,189,235,212,116,95,139,176,238,145,26,152,37,133,165,180,161,42,67,240,149,143,98,130,190,211,157,178,55,219,189,7,30,131,61,200,241,29,94,168,66,1,153,122,154,249,29,200,170,126,214,211,173,188,241,37,100,183,144,15,198,54,254,40,94,193,107,154,252,177,33,229,16,215,222,227,157,66,83,220,154,47,208,50,145,118,64,182,135,80,204,196,100,43,137,120,36,3,213,59,28,145,226,188,61,68,186,254,26,202,172,240,231,71,117,25,247,190,211,65,42,81,240,172,118,249,25,21,125,49,129,193,70,228,53,14,94,230,234,8,235,93,64,187,196,198,227,180,120,96,68,28,182,80,59,249,81,242,77,13,87,211,185,57,235,95,42,245,80,162,194,70,205,145,188,117,235,253,43,54,221,172,214,46,113,90,131,41,226,30,75,45,47,137,32,124,17,91,94,155,63,108,123,83,75,135,168,173,142,206,10,103,12,54,194,56,200,88,242,42,183,168,218,173,26,135,84,198,188,8,229,213,112,37,183,16,114,1,72,241,227,173,85,129,114,58,115,81,38,243,0,148,62,180,16,140,36,240,140,246,223,173,101,146,196,88,192,233,175,226,92,190,183,114,151,62,67,144,237,238,91,217,134,176,12,69,123,85,249,227,166,107,210,240,143,171,138,30,159,37,150,134,220,109,72,36,40,171,169,1,0,103,245,59,124,213,25,58,130,125,206,90,222,83,202,18,150,172,241,13,178,107,10,249,58,233,45,193,14,115,238,41,168,75,10,74,84,114,56,149,191,111,184,227,125,201,197,21,36,201,172,124,66,91,147,113,26,158,155,199,76,184,146,33,150,13,187,152,2,154,39,33,46,120,56,38,140,236,154,42,193,109,131,46,233,57,14,197,133,111,74,228,200,75,99,37,68,12,158,28,118,216,210,123,76,106,142,123,28,229,190,212,101,70,27,41,106,42,90,199,124,138,62,78,179,224,67,246,254,107,100,77,107,133,113,92,78,126,225,215,35,177,7,167,241,64,41,46,100,56,154,0,212,41,149,57,66,219,123,177,122,147,114,69,144,72,126,42,167,165,197,67,5,196,47,42,72,39,133,88,57,7,31,198,41,121,168,52,18,116,229,245,46,54,242,165,60,85,129,29,0,30,89,198,228,239,231,160,236,107,115,71,91,226,233,29,72,187,188,88,234,114,98,74,208,207,53,240,164,54,14,219,28,12,28,28,111,189,49,37,221,45,22,171,60,139,197,241,246,100,75,113,39,13,130,61,185,206,0,207,106,161,169,170,15,215,168,145,85,152,128,251,156,181,168,173,230,197,119,43,101,231,218,146,133,135,18,135,27,9,82,123,245,4,138,196,151,45,201,106,227,124,241,57,254,93,205,18,235,171,221,190,242,247,28,104,225,15,165,100,243,18,118,82,79,98,62,40,70,170,164,14,32,183,113,21,14,200,29,73,82,165,74,108,92,111,178,25,76,9,130,230,165,9,164,142,80,79,64,154,210,212,55,183,111,86,187,116,66,134,131,81,144,18,149,33,56,36,14,185,173,61,5,161,142,179,110,114,140,192,195,49,144,120,148,78,249,241,84,156,114,108,185,48,161,90,237,236,45,216,106,228,163,183,22,15,220,71,142,245,147,172,190,234,116,41,58,19,213,242,132,8,77,179,29,13,45,73,5,180,171,124,15,242,53,157,117,104,77,188,70,105,201,140,197,142,227,200,140,22,225,9,73,81,32,21,146,122,1,157,201,219,2,152,151,141,29,49,228,34,225,13,198,19,35,0,56,218,201,74,71,202,127,234,138,45,58,111,79,34,206,210,69,178,12,231,155,79,18,156,125,144,165,40,157,201,223,63,181,36,86,90,38,230,105,167,20,227,136,147,212,143,75,52,52,45,9,42,239,25,151,97,174,219,8,186,137,144,220,247,72,82,71,180,168,28,165,101,74,199,184,121,235,74,119,224,92,244,165,154,14,162,191,199,183,75,65,105,0,100,40,172,23,19,176,90,54,226,35,200,61,169,220,195,58,62,229,99,93,138,227,17,203,125,189,242,56,211,29,197,178,210,148,14,70,64,216,110,1,233,189,103,122,165,233,219,250,202,211,22,13,154,245,5,13,178,231,48,37,228,40,115,8,78,18,9,4,227,25,61,187,213,244,157,57,11,144,138,74,245,248,44,81,78,143,99,193,156,243,26,99,23,91,125,218,68,155,211,205,44,165,33,166,154,109,74,76,133,113,103,133,71,251,112,55,222,188,255,0,14,146,225,180,148,75,141,50,68,144,180,178,195,139,7,149,185,78,92,7,1,57,220,130,79,65,154,167,120,184,234,61,6,171,150,145,146,204,116,142,111,26,210,166,195,160,146,7,185,10,238,8,2,177,116,140,25,215,125,67,26,18,150,235,98,66,248,120,156,4,32,19,241,255,0,2,137,232,216,100,12,190,135,229,209,174,149,105,143,162,221,107,253,131,183,24,202,139,41,77,168,109,212,17,208,143,53,86,186,75,83,127,78,194,68,71,100,89,117,35,14,206,105,176,165,50,251,65,13,171,224,44,40,227,161,236,107,158,46,214,249,22,171,148,152,51,80,17,34,58,203,107,0,228,100,120,61,197,80,141,112,38,53,96,190,163,97,213,245,42,84,169,82,142,42,127,255,217]} } \ No newline at end of file diff --git a/test/_fixtures/thumbnailBufferFromUri.json b/test/_fixtures/thumbnailBufferFromUri.json index 209680e..0a4fdff 100644 --- a/test/_fixtures/thumbnailBufferFromUri.json +++ b/test/_fixtures/thumbnailBufferFromUri.json @@ -1,3 +1,3 @@ { - "buffer": {"type":"Buffer","data":[255,216,255,219,0,67,0,6,4,5,6,5,4,6,6,5,6,7,7,6,8,10,16,10,10,9,9,10,20,14,15,12,16,23,20,24,24,23,20,22,22,26,29,37,31,26,27,35,28,22,22,32,44,32,35,38,39,41,42,41,25,31,45,48,45,40,48,37,40,41,40,255,219,0,67,1,7,7,7,10,8,10,19,10,10,19,40,26,22,26,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,255,192,0,17,8,0,64,0,96,3,1,34,0,2,17,1,3,17,1,255,196,0,28,0,0,2,2,3,1,1,0,0,0,0,0,0,0,0,0,0,5,7,4,6,0,3,8,1,2,255,196,0,52,16,0,1,3,3,3,2,4,5,2,5,5,0,0,0,0,0,1,2,3,4,0,5,17,6,18,33,49,65,7,19,34,81,20,50,97,113,129,21,145,8,82,161,177,209,35,51,66,67,193,255,196,0,25,1,0,3,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,3,4,5,0,1,255,196,0,38,17,0,2,1,4,2,1,3,5,1,0,0,0,0,0,0,0,1,2,0,3,17,18,33,4,49,65,19,34,81,5,35,113,129,225,240,255,218,0,12,3,1,0,2,17,3,17,0,63,0,86,20,221,159,129,120,98,34,217,92,6,156,216,227,136,24,220,1,224,138,143,105,178,201,90,12,169,13,164,69,9,36,19,222,134,173,217,246,221,241,212,165,182,48,10,209,252,198,173,90,157,171,194,45,54,207,138,67,109,54,250,2,146,150,149,242,231,222,178,222,227,66,214,51,134,186,151,40,158,16,185,62,221,18,108,153,140,179,25,72,14,37,41,228,144,70,71,52,10,251,225,4,198,16,185,48,28,143,49,156,255,0,214,118,172,126,15,7,247,166,39,133,90,145,219,134,156,147,167,46,100,46,92,70,50,194,192,255,0,113,3,183,222,171,177,245,11,150,219,194,163,33,197,22,22,172,22,214,113,248,20,55,42,46,12,168,83,87,176,180,65,106,155,13,194,214,242,254,54,50,154,9,56,206,48,14,106,187,93,83,123,211,173,106,150,76,39,10,194,30,56,74,136,229,6,150,86,175,4,174,174,201,121,23,89,140,196,74,14,2,90,30,106,136,237,158,128,85,20,121,168,86,239,169,207,196,101,54,77,197,29,101,56,39,120,58,134,74,155,98,228,234,158,237,189,160,7,247,170,109,231,64,94,173,50,152,110,67,33,108,188,226,91,14,182,114,50,78,57,29,105,233,201,164,253,24,15,198,168,157,137,82,0,158,130,188,166,36,125,55,29,15,121,77,179,230,12,227,113,61,135,127,165,67,153,18,206,46,73,143,10,34,92,0,225,100,171,169,238,126,148,43,201,87,62,217,205,199,101,27,148,122,202,97,234,173,39,109,183,233,209,114,47,8,207,175,134,216,221,146,191,197,47,41,200,225,197,196,83,41,88,238,179,56,155,130,37,183,34,214,101,203,216,165,5,142,72,250,208,249,18,102,136,236,124,96,90,192,244,180,23,211,142,216,163,254,4,220,33,163,91,73,141,120,152,152,172,60,202,182,149,156,100,142,217,237,81,47,210,163,70,214,42,68,87,215,50,223,29,245,109,82,135,204,156,255,0,122,204,42,85,142,162,205,231,214,157,188,185,108,190,196,148,134,195,14,167,9,80,219,243,125,199,122,102,221,236,118,203,217,76,184,43,140,183,31,245,56,219,129,64,160,247,227,29,42,61,154,30,159,158,227,114,238,139,66,27,62,184,155,15,36,227,161,163,48,245,20,29,44,137,238,75,119,49,16,156,162,59,40,25,82,190,253,73,250,210,115,63,18,174,61,66,69,140,208,234,27,211,22,50,164,60,151,31,95,165,24,206,83,251,242,104,174,151,98,107,118,55,102,200,142,75,202,36,171,127,10,25,239,131,74,203,230,170,187,234,57,114,174,86,152,79,67,133,17,181,60,202,220,107,119,172,14,58,240,125,241,80,244,6,185,191,200,146,166,228,42,92,197,201,103,202,113,79,190,28,37,127,204,8,0,0,127,151,146,49,94,122,36,134,127,137,120,169,107,32,243,46,111,205,91,215,119,65,72,243,18,163,148,208,237,121,119,253,41,136,206,249,101,14,161,65,91,22,58,208,153,41,185,105,171,154,174,215,52,169,76,33,194,82,144,50,85,233,227,63,154,168,222,188,65,85,253,169,16,46,49,154,154,228,148,44,165,65,5,14,195,112,124,184,87,69,3,220,99,247,160,227,208,103,185,29,8,218,245,130,16,12,29,170,111,8,126,38,251,84,119,218,83,185,43,86,205,220,253,49,199,239,64,116,245,162,72,127,226,229,44,166,50,48,183,87,212,1,86,253,1,49,171,211,41,128,37,38,52,134,199,175,214,82,162,7,116,123,227,218,133,248,141,121,12,131,104,135,61,15,48,217,57,117,182,194,74,143,178,241,215,239,205,104,83,24,159,77,70,228,53,13,253,205,42,90,194,252,237,242,229,184,157,177,88,30,91,13,142,137,72,255,0,211,64,107,211,214,188,171,149,66,139,9,19,28,141,227,163,89,233,105,118,189,108,251,87,38,153,141,53,74,243,188,166,213,148,140,251,31,106,177,248,93,38,3,215,139,156,75,205,161,203,148,130,216,49,208,202,2,246,168,123,143,175,20,43,91,234,116,222,245,138,47,63,14,93,243,2,82,234,85,192,192,224,26,248,183,93,28,210,247,215,46,86,229,41,18,31,65,74,72,65,9,193,237,205,101,146,196,88,193,26,107,248,146,110,172,221,165,220,29,150,196,53,67,76,87,66,62,16,28,41,39,220,1,197,108,189,180,135,89,75,243,164,178,158,70,89,123,37,106,87,182,209,211,243,138,128,229,234,125,198,82,156,15,44,73,82,179,184,113,147,64,239,19,110,114,95,75,83,159,117,109,192,88,67,105,42,42,0,227,39,0,117,35,142,78,104,232,174,71,126,33,45,239,113,27,190,31,68,248,219,115,240,158,99,244,247,21,235,66,15,9,88,199,4,130,120,205,91,173,250,95,78,233,251,28,203,244,246,30,102,21,177,181,60,182,154,25,43,87,94,49,219,252,210,123,76,234,160,244,116,201,114,67,81,150,198,0,78,74,150,177,245,251,213,225,205,92,28,102,101,156,184,133,166,90,10,92,138,224,249,73,28,242,59,28,244,237,64,180,151,50,28,77,27,213,41,149,57,10,207,115,178,248,153,49,86,98,243,172,73,144,195,143,197,72,117,43,4,167,146,21,142,135,167,245,165,245,235,67,53,96,191,17,21,199,37,186,178,83,229,35,24,100,99,158,188,103,147,86,13,15,21,157,29,120,122,227,5,141,243,92,10,105,46,61,35,122,80,146,122,3,129,142,63,53,122,186,222,108,182,11,11,247,11,164,134,165,78,121,56,218,10,114,9,237,207,56,167,178,5,31,111,81,34,163,177,25,238,114,237,250,31,232,119,117,24,238,188,220,134,215,184,37,105,0,167,242,9,20,26,68,149,200,245,59,202,250,110,238,104,254,181,188,194,188,62,135,35,71,13,188,146,119,56,158,139,29,179,245,170,197,87,76,28,65,110,228,206,118,64,234,101,101,101,101,50,4,111,183,240,232,182,200,76,245,40,92,60,193,183,29,2,40,158,165,189,61,126,106,3,110,33,191,42,58,18,148,249,105,193,80,20,87,67,232,35,171,237,119,9,138,151,228,177,25,7,147,213,68,118,168,77,191,58,229,115,128,221,178,3,30,99,4,52,1,233,132,240,84,71,181,100,235,47,246,167,170,172,116,60,205,178,10,83,38,43,44,176,134,86,82,10,82,121,216,159,127,189,14,118,51,55,77,75,6,60,169,237,67,137,38,66,99,133,184,66,64,25,1,75,39,182,63,197,48,111,26,54,82,148,155,132,39,89,73,86,3,169,89,198,209,220,167,223,237,86,184,58,119,79,53,105,104,34,213,6,90,154,71,43,121,144,165,31,114,115,205,36,86,74,38,230,105,175,20,227,138,200,254,46,248,107,162,173,186,30,109,250,223,21,216,18,32,198,10,142,236,53,227,207,115,132,160,41,39,133,100,145,234,31,83,205,43,238,176,238,90,38,4,123,197,241,171,116,146,234,18,202,87,177,69,65,75,78,65,82,59,169,56,234,13,59,90,143,163,175,22,150,236,215,24,174,65,136,165,165,196,33,167,84,219,69,196,156,131,183,167,30,212,35,197,143,13,102,107,88,145,25,180,221,225,165,17,148,183,2,30,109,67,204,81,24,228,130,113,129,90,20,153,57,10,28,69,39,34,191,9,138,3,163,216,61,25,207,109,72,143,113,178,220,100,200,188,72,75,229,104,12,178,219,100,182,241,207,37,71,254,36,3,253,107,225,219,108,135,28,128,148,76,139,46,76,152,235,216,133,172,127,160,146,14,119,103,1,42,198,77,14,188,222,181,14,144,102,118,144,150,211,13,37,151,148,86,133,182,22,66,142,57,74,186,16,112,14,113,80,116,29,174,101,251,82,70,183,23,92,64,124,227,115,153,41,28,251,119,235,211,235,94,189,28,70,74,102,133,31,171,35,221,42,211,31,159,215,199,246,85,38,178,168,242,86,218,134,58,17,246,35,34,180,87,71,234,175,225,220,187,18,68,203,6,160,106,68,150,146,10,153,144,216,66,21,199,64,176,78,63,34,185,222,116,87,160,205,126,44,148,236,121,149,150,214,156,231,4,28,26,165,26,226,98,85,3,51,143,87,154,43,43,43,40,162,231,255,217]} + "buffer": {"type":"Buffer","data":[255,216,255,219,0,67,0,6,4,5,6,5,4,6,6,5,6,7,7,6,8,10,16,10,10,9,9,10,20,14,15,12,16,23,20,24,24,23,20,22,22,26,29,37,31,26,27,35,28,22,22,32,44,32,35,38,39,41,42,41,25,31,45,48,45,40,48,37,40,41,40,255,219,0,67,1,7,7,7,10,8,10,19,10,10,19,40,26,22,26,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,255,192,0,17,8,0,64,0,96,3,1,34,0,2,17,1,3,17,1,255,196,0,28,0,0,2,3,1,1,1,1,0,0,0,0,0,0,0,0,0,6,7,0,4,5,8,3,1,2,255,196,0,53,16,0,1,3,3,3,2,5,2,4,4,7,0,0,0,0,0,1,2,3,4,0,5,17,6,18,33,49,65,7,19,34,81,97,50,177,20,21,66,129,8,82,113,145,36,114,130,193,209,225,240,255,196,0,25,1,0,3,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,3,4,5,1,0,255,196,0,37,17,0,2,1,4,2,0,6,3,0,0,0,0,0,0,0,0,1,2,0,3,17,18,33,4,49,5,19,34,65,81,240,35,50,225,255,218,0,12,3,1,0,2,17,3,17,0,63,0,88,56,155,171,127,158,192,130,220,103,99,178,75,111,60,208,224,128,79,34,179,109,22,137,82,21,231,56,207,248,84,131,149,158,245,81,50,110,54,196,184,202,148,166,188,196,133,58,158,155,168,162,246,171,195,122,102,218,226,227,166,52,121,9,5,33,179,207,239,247,172,183,186,254,182,220,240,212,38,183,248,75,50,239,106,137,51,206,98,60,53,167,204,79,171,37,64,244,172,155,247,131,247,24,161,114,33,134,38,48,58,150,87,235,31,233,61,127,189,50,60,30,212,110,202,177,59,166,110,128,25,81,216,42,140,177,250,208,57,199,245,172,65,168,156,181,222,23,29,14,41,76,45,91,84,218,206,49,240,51,66,24,168,184,50,161,77,30,194,115,222,166,178,78,183,60,177,42,42,217,8,61,74,72,4,30,134,135,235,170,47,214,70,181,43,6,34,202,130,31,59,82,84,57,65,52,170,133,224,189,245,217,239,179,57,230,33,52,133,16,149,19,230,41,67,36,3,180,116,7,228,213,20,121,136,203,235,213,167,31,136,202,108,155,138,202,148,217,157,224,235,209,201,66,46,129,110,246,5,140,15,189,7,95,116,61,238,204,180,254,38,54,246,84,160,128,235,103,41,201,56,25,246,167,167,38,147,232,24,13,199,168,155,34,12,0,79,74,249,71,237,105,118,89,120,50,26,83,203,7,105,35,220,117,170,247,43,109,158,60,228,70,142,194,157,112,28,56,119,241,158,248,174,47,37,24,216,78,158,59,40,185,129,21,41,135,125,209,176,98,233,197,221,124,225,19,31,67,107,86,75,135,224,82,242,154,142,31,168,166,82,189,199,109,161,214,46,79,190,137,246,215,37,201,82,84,80,83,215,224,227,218,168,63,54,97,132,202,38,7,20,194,14,214,146,190,0,199,106,216,240,78,116,113,226,26,88,186,75,68,104,239,54,164,133,56,113,146,59,3,218,191,90,205,232,209,53,155,177,161,202,51,160,179,33,68,40,129,133,14,14,50,61,185,31,181,102,21,33,237,104,179,126,229,107,21,225,86,235,204,57,141,182,150,30,65,194,142,62,175,235,77,11,213,146,217,125,66,46,17,23,21,111,62,1,91,74,86,210,149,119,35,226,170,217,173,218,126,234,235,82,238,107,75,16,206,23,29,73,32,18,161,158,15,113,207,106,223,183,94,32,233,167,230,185,41,212,38,18,27,220,91,67,97,75,90,191,205,212,159,142,130,147,153,248,148,241,170,19,163,43,49,29,26,102,200,183,212,250,28,112,13,173,225,68,237,253,251,255,0,238,107,67,72,162,91,214,201,23,25,12,41,199,20,73,202,184,56,247,193,165,190,160,213,243,117,69,201,199,172,144,31,106,4,100,23,130,228,50,84,20,180,130,64,61,136,239,142,248,172,221,9,226,46,160,122,224,159,199,59,50,115,143,180,91,119,205,113,7,42,57,193,64,74,70,212,244,27,78,79,112,123,87,60,146,217,63,86,151,138,150,178,252,195,89,243,148,245,225,105,41,1,96,253,34,168,107,139,154,32,91,152,116,163,14,37,65,91,22,158,21,253,251,86,60,182,238,118,123,199,230,183,68,171,240,136,113,39,24,202,148,49,246,206,40,94,245,226,50,47,197,216,119,72,141,76,18,194,210,218,80,149,33,232,74,199,161,65,95,73,207,25,28,241,222,131,143,65,158,228,110,209,213,234,132,32,25,151,169,175,145,220,138,167,237,109,58,219,207,18,86,75,121,0,252,99,143,181,11,216,109,115,95,150,36,60,162,26,250,220,115,168,74,123,147,69,250,6,82,46,200,22,208,234,25,152,156,133,110,94,9,0,245,79,7,36,123,87,135,136,151,95,203,89,85,158,28,232,238,163,62,183,218,104,37,74,63,202,172,118,249,25,21,125,49,129,242,212,110,67,80,229,234,99,168,35,173,111,235,188,76,110,59,71,108,8,131,203,101,3,191,186,143,185,52,53,95,85,201,57,235,95,42,245,80,162,194,70,205,145,188,117,235,253,43,54,221,172,212,46,113,90,131,41,210,30,75,13,47,114,64,248,34,182,188,54,126,216,238,165,151,15,81,91,29,156,20,206,24,109,132,111,33,99,220,85,111,17,117,90,53,14,169,141,120,17,203,170,218,150,220,65,200,5,35,219,218,170,192,185,29,57,168,147,121,128,162,135,214,130,17,132,157,163,61,185,235,89,100,177,22,48,58,107,251,75,151,214,238,82,231,200,92,59,123,150,246,97,172,3,17,94,149,127,92,116,205,122,94,17,248,184,161,233,242,89,104,113,189,185,4,133,21,117,32,32,115,251,158,62,106,132,173,65,62,233,45,111,41,229,9,43,86,119,14,57,172,59,228,235,172,183,4,57,207,184,166,161,44,41,41,39,35,114,185,237,245,28,28,242,78,62,40,168,174,77,99,9,110,77,196,106,120,111,29,50,226,72,134,88,54,239,48,5,52,78,66,92,246,56,38,140,236,186,42,193,109,131,46,233,57,14,197,133,111,74,228,200,75,99,37,68,12,157,184,237,193,164,246,152,213,30,123,1,229,190,212,101,70,28,41,106,42,90,199,124,138,62,78,179,216,135,237,254,107,100,77,107,106,226,184,156,253,67,174,71,98,15,79,181,0,164,185,144,226,104,3,80,166,84,229,11,109,238,197,226,77,201,54,65,33,248,166,122,92,84,64,92,66,242,164,130,118,171,7,32,227,237,138,94,106,13,6,157,57,125,74,219,121,82,158,42,192,142,128,15,150,113,201,60,251,244,29,141,110,104,235,124,93,35,169,23,119,139,29,78,76,73,82,25,243,100,5,33,160,120,224,224,96,224,227,158,105,137,46,233,104,181,89,228,94,47,143,179,34,99,137,56,108,17,233,206,112,6,123,85,13,77,80,126,61,68,138,172,196,7,220,229,173,69,111,54,43,185,91,47,62,212,148,44,56,148,56,216,73,79,126,160,145,88,146,165,185,45,69,111,250,156,254,110,230,137,117,213,238,223,121,123,124,104,225,15,165,100,249,137,60,41,39,177,31,20,35,85,82,7,16,91,184,135,109,144,58,146,165,74,148,216,184,223,96,50,152,19,5,205,74,19,73,30,80,79,64,154,210,212,55,183,111,86,187,116,66,134,131,81,144,18,149,33,56,42,29,235,79,64,232,99,172,155,156,163,48,48,204,100,29,202,39,146,125,170,147,142,77,151,38,20,59,93,189,133,187,13,94,74,59,110,193,198,226,61,187,214,78,178,251,169,208,164,232,123,207,87,202,16,33,54,204,116,52,181,36,22,210,174,112,15,234,53,157,117,104,77,188,70,105,201,140,197,142,227,200,140,22,225,9,73,81,32,21,146,122,1,158,79,76,10,98,94,52,116,199,155,69,194,27,140,38,70,0,113,181,146,148,143,148,255,0,197,20,90,116,222,158,69,157,164,139,100,25,207,33,59,148,227,236,133,41,68,242,79,57,52,145,89,104,155,153,166,156,83,142,34,79,18,60,44,208,208,180,36,171,188,118,93,134,187,108,34,242,38,67,115,213,33,73,30,146,160,114,149,149,43,30,161,239,214,149,15,192,185,233,59,52,29,69,127,143,110,150,130,210,49,144,162,176,92,79,1,104,227,113,30,224,246,167,108,118,116,125,202,198,187,21,198,35,150,251,123,228,111,76,119,86,203,74,80,57,25,0,224,114,1,233,205,103,120,165,225,227,250,202,209,22,13,154,245,5,13,178,239,152,18,242,8,243,8,78,18,9,4,227,25,61,187,213,244,157,57,10,24,69,37,122,252,22,40,167,71,177,236,103,60,198,152,197,214,223,118,145,38,244,243,75,218,144,211,77,54,165,38,66,183,103,106,143,233,192,230,188,205,186,67,134,210,81,50,52,217,18,66,210,203,14,44,31,43,146,156,184,14,2,115,201,4,158,131,53,78,241,113,212,122,13,87,45,35,37,152,233,30,110,245,165,77,135,65,36,15,82,21,220,16,7,253,86,46,145,131,58,239,168,99,66,82,221,111,241,11,219,185,192,66,1,63,31,236,40,158,141,134,74,101,244,60,93,26,233,86,152,250,45,215,246,14,220,99,42,44,181,182,161,199,80,71,66,61,234,173,116,150,166,254,29,132,136,142,201,178,234,70,29,156,211,97,74,101,246,130,27,87,192,88,81,199,67,216,215,60,93,173,242,45,87,41,48,102,160,34,68,117,150,214,1,200,200,246,61,197,80,141,112,38,53,96,190,99,97,213,245,42,84,169,82,142,42,127,255,217]} } \ No newline at end of file diff --git a/test/imageThumbnail.test.js b/test/imageThumbnail.test.js index e43b6ec..630c11a 100644 --- a/test/imageThumbnail.test.js +++ b/test/imageThumbnail.test.js @@ -4,6 +4,7 @@ const fs = require('fs'); const sizeOf = require('image-size'); const imageThumbnail = require('../src'); const fixtures = require('./_fixtures'); +const util = require('../src/util'); const IMAGE_PATH = './resources/images/dog.jpg'; describe('Image Thumbnail', () => { @@ -48,7 +49,7 @@ describe('Image Thumbnail', () => { it('should return a base64 image thumbnail from an image base64', async () => { const options = { responseType: 'base64' }; const thumbnail = await imageThumbnail(fixtures.imageBase64, options); - + expect(thumbnail).toEqual(fixtures.thumbnailBase64FromBase64); }); @@ -86,7 +87,7 @@ describe('Image Thumbnail', () => { describe('Options', () => { it('should return a buffer image and keep aspect 300x200', async () => { - const options = { width: 300, height: 200}; + const options = { width: 300, height: 200 }; const imageBuffer = fs.readFileSync(IMAGE_PATH); const thumbnail = await imageThumbnail(imageBuffer, options); const dimensions = sizeOf(thumbnail); @@ -96,29 +97,29 @@ describe('Image Thumbnail', () => { }); it('should return a buffer image with width equals 300', async () => { - const options = { width: 300}; + const options = { width: 300 }; const imageBuffer = fs.readFileSync(IMAGE_PATH); const thumbnail = await imageThumbnail(imageBuffer, options); const dimensions = sizeOf(thumbnail); expect(dimensions.width).toEqual(300); - expect(dimensions.height).toEqual(639); + expect(dimensions.height).toEqual(200); }); it('should return a buffer image with height equals 300', async () => { - const options = { height: 300}; + const options = { height: 300 }; const imageBuffer = fs.readFileSync(IMAGE_PATH); const thumbnail = await imageThumbnail(imageBuffer, options); const dimensions = sizeOf(thumbnail); - expect(dimensions.width).toEqual(960); + expect(dimensions.width).toEqual(451); expect(dimensions.height).toEqual(300); }); it('should return a buffer image with width equals 300 and height equals 200', async () => { - const options = { width: 300, height: 200}; + const options = { width: 300, height: 200 }; const imageBuffer = fs.readFileSync(IMAGE_PATH); const thumbnail = await imageThumbnail(imageBuffer, options); const dimensions = sizeOf(thumbnail); @@ -127,18 +128,18 @@ describe('Image Thumbnail', () => { expect(dimensions.height).toEqual(200); }); - it('should return a buffer image with width equals 960 and height equals 200', async () => { - const options = { height: 200}; + it('should return a buffer image with width quals 200', async () => { + const options = { height: 200 }; const imageBuffer = fs.readFileSync(IMAGE_PATH); const thumbnail = await imageThumbnail(imageBuffer, options); const dimensions = sizeOf(thumbnail); - expect(dimensions.width).toEqual(960); + expect(dimensions.width).toEqual(300); expect(dimensions.height).toEqual(200); }); it('should return a buffer image with width equals 144 and height equals 96', async () => { - const options = { percentage: 15}; + const options = { percentage: 15 }; const imageBuffer = fs.readFileSync(IMAGE_PATH); const thumbnail = await imageThumbnail(imageBuffer, options); const dimensions = sizeOf(thumbnail); @@ -147,4 +148,34 @@ describe('Image Thumbnail', () => { expect(dimensions.height).toEqual(96); }); }); + + describe('Utils', () => { + describe('RemoveUndefined', () => { + it('should return an object only with height', async () => { + const originalObject = { width: undefined, height: 200 }; + + const newObject = util.removeUndefined(originalObject) + + expect(newObject).toEqual({ height: 200 }); + }); + + it('should return an object only with width', async () => { + const originalObject = { width: 200, height: undefined }; + + const newObject = util.removeUndefined(originalObject) + + expect(newObject).toEqual({ width: 200 }); + + }); + + it('should return an object with width and height', async () => { + const originalObject = { width: 200, height: 200 }; + + const newObject = util.removeUndefined(originalObject) + + expect(newObject).toEqual(originalObject); + + }); + }); + }); }); \ No newline at end of file