@eris/image
Advanced tools
Comparing version 0.3.1-alpha.9 to 0.3.1-alpha.10
@@ -18,6 +18,9 @@ "use strict"; | ||
function sharpness(imageData, options) { | ||
const threshold = (options && options.threshold) || 20; | ||
const defaultSubselect = { x: 0, y: 0, width: imageData.width, height: imageData.height }; | ||
const { threshold = 20, subselect = defaultSubselect } = options || {}; | ||
const maxX = subselect.x + subselect.width; | ||
const maxY = subselect.y + subselect.height; | ||
let edgePixelIntensities = []; | ||
for (let y = 0; y < imageData.height; y++) { | ||
for (let x = 0; x < imageData.width; x++) { | ||
for (let y = subselect.y; y < maxY; y++) { | ||
for (let x = 0; x < maxX; x++) { | ||
const pixel = image_data_1.ImageData.valueFor(imageData, x, y); | ||
@@ -24,0 +27,0 @@ if (pixel > threshold) { |
@@ -16,2 +16,3 @@ "use strict"; | ||
const hash_1 = require("./analyses/hash"); | ||
const faces_1 = require("./analyses/faces"); | ||
const sharpness_1 = require("./analyses/sharpness"); | ||
@@ -132,3 +133,3 @@ const histograms_1 = require("./analyses/histograms"); | ||
} | ||
const { hash, sharpness, histograms, composition } = this._analyze; | ||
const { hash, faces, sharpness, histograms, composition } = this._analyze; | ||
if (Object.keys(this._analyze).length === 0) { | ||
@@ -156,2 +157,10 @@ return Promise.resolve({}); | ||
} | ||
if (faces) { | ||
analysis.faces = yield faces_1.detectFaces(imageData); | ||
if (sharpness) { | ||
for (const face of analysis.faces.slice(0, 3)) { | ||
face.sharpness = sharpness_1.sharpness(edges, Object.assign({}, sharpness, { subselect: face.boundingBox })); | ||
} | ||
} | ||
} | ||
return analysis; | ||
@@ -158,0 +167,0 @@ }); |
@@ -78,2 +78,3 @@ /// <reference types="node" /> | ||
hash?: IHashOptions; | ||
faces?: IFaceAnalysisOptions; | ||
sharpness?: ISharpnessOptions; | ||
@@ -109,3 +110,8 @@ histograms?: IHistogramOptions; | ||
threshold?: number; | ||
subselect?: IBoundingBox; | ||
} | ||
export interface IFaceAnalysisOptions { | ||
/** The minimum confidence to include faces for analysis, typically a number 0.5-1.0. */ | ||
threshold?: number; | ||
} | ||
export interface IHistogramOptions { | ||
@@ -137,2 +143,9 @@ /** The number of histogram buckets to compute */ | ||
} | ||
export interface IFaceAnalysisEntry { | ||
confidence: number; | ||
happinessConfidence: number; | ||
boundingBox: IBoundingBox; | ||
eyes: IBoundingBox[]; | ||
sharpness?: ISharpnessAnalysis; | ||
} | ||
export interface ISharpnessAnalysis { | ||
@@ -159,2 +172,3 @@ percentEdges: number; | ||
hash?: string; | ||
faces?: IFaceAnalysisEntry[]; | ||
sharpness?: ISharpnessAnalysis; | ||
@@ -239,2 +253,8 @@ histograms?: IHistogramsAnalysis; | ||
} | ||
export interface IBoundingBox { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
} | ||
export interface IBasePixel extends IPixelCoordinate { | ||
@@ -241,0 +261,0 @@ index: number; |
@@ -23,7 +23,10 @@ import {ISharpnessAnalysis, ISharpnessOptions} from '../types' | ||
): ISharpnessAnalysis { | ||
const threshold = (options && options.threshold) || 20 | ||
const defaultSubselect = {x: 0, y: 0, width: imageData.width, height: imageData.height} | ||
const {threshold = 20, subselect = defaultSubselect} = options || {} | ||
const maxX = subselect.x + subselect.width | ||
const maxY = subselect.y + subselect.height | ||
let edgePixelIntensities: number[] = [] | ||
for (let y = 0; y < imageData.height; y++) { | ||
for (let x = 0; x < imageData.width; x++) { | ||
for (let y = subselect.y; y < maxY; y++) { | ||
for (let x = 0; x < maxX; x++) { | ||
const pixel = ImageData.valueFor(imageData, x, y) | ||
@@ -30,0 +33,0 @@ if (pixel > threshold) { |
@@ -6,2 +6,3 @@ import * as types from './types' | ||
import {phash} from './analyses/hash' | ||
import {detectFaces as computeFaces} from './analyses/faces' | ||
import {sharpness as computeSharpness} from './analyses/sharpness' | ||
@@ -146,3 +147,3 @@ import {histograms as computeHistograms} from './analyses/histograms' | ||
const {hash, sharpness, histograms, composition} = this._analyze | ||
const {hash, faces, sharpness, histograms, composition} = this._analyze | ||
if (Object.keys(this._analyze).length === 0) { | ||
@@ -180,2 +181,12 @@ return Promise.resolve({}) | ||
if (faces) { | ||
analysis.faces = await computeFaces(imageData) | ||
if (sharpness) { | ||
for (const face of analysis.faces.slice(0, 3)) { | ||
face.sharpness = computeSharpness(edges!, {...sharpness, subselect: face.boundingBox}) | ||
} | ||
} | ||
} | ||
return analysis | ||
@@ -182,0 +193,0 @@ } |
@@ -87,2 +87,3 @@ import {INormalizedMetadata} from '@eris/exif' | ||
hash?: IHashOptions | ||
faces?: IFaceAnalysisOptions | ||
sharpness?: ISharpnessOptions | ||
@@ -124,4 +125,10 @@ histograms?: IHistogramOptions | ||
threshold?: number | ||
subselect?: IBoundingBox | ||
} | ||
export interface IFaceAnalysisOptions { | ||
/** The minimum confidence to include faces for analysis, typically a number 0.5-1.0. */ | ||
threshold?: number | ||
} | ||
export interface IHistogramOptions { | ||
@@ -157,2 +164,10 @@ /** The number of histogram buckets to compute */ | ||
export interface IFaceAnalysisEntry { | ||
confidence: number | ||
happinessConfidence: number | ||
boundingBox: IBoundingBox | ||
eyes: IBoundingBox[] | ||
sharpness?: ISharpnessAnalysis | ||
} | ||
export interface ISharpnessAnalysis { | ||
@@ -182,2 +197,3 @@ percentEdges: number | ||
hash?: string | ||
faces?: IFaceAnalysisEntry[] | ||
sharpness?: ISharpnessAnalysis | ||
@@ -274,2 +290,9 @@ histograms?: IHistogramsAnalysis | ||
export interface IBoundingBox { | ||
x: number | ||
y: number | ||
width: number | ||
height: number | ||
} | ||
export interface IBasePixel extends IPixelCoordinate { | ||
@@ -276,0 +299,0 @@ index: number |
{ | ||
"name": "@eris/image", | ||
"version": "0.3.1-alpha.9", | ||
"version": "0.3.1-alpha.10", | ||
"description": "Collection of image manipulation libraries for node and the browser.", | ||
@@ -14,11 +14,6 @@ "main": "./dist/node-index.js", | ||
"test": "npm run test:lint && npm run test:unit", | ||
"test:unit": "mocha --require source-map-support/register --timeout 20000 --reporter spec --recursive ./test", | ||
"test:unit": "jest", | ||
"test:lint": "lint", | ||
"test:update-expectations": "cross-env UPDATE_EXPECTATIONS=true npm run test:unit", | ||
"test:upload": "bash test/fixtures/upload.sh", | ||
"test:update-all": "npm run test:update-expectations && npm run test:upload", | ||
"test:download": "bash test/fixtures/download.sh", | ||
"test:coverage": "nyc npm run test:unit", | ||
"test:watch": "mocha --watch --reporter dot 'test/**/*.test.js'", | ||
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post" | ||
"test:watch": "jest --watch" | ||
}, | ||
@@ -39,5 +34,7 @@ "publishConfig": { | ||
"dependencies": { | ||
"@eris/exif": "0.3.1-alpha.9", | ||
"@eris/exif": "0.3.1-alpha.10", | ||
"@tensorflow/tfjs-node": "^1.0.3", | ||
"@types/sharp": "^0.22.0", | ||
"buffer": "^5.2.0", | ||
"face-api.js": "^0.19.0", | ||
"file-type": "^7.0.1", | ||
@@ -52,9 +49,4 @@ "jpeg-js": "^0.3.4", | ||
"babili": "^0.1.2", | ||
"chai": "^3.5.0", | ||
"cross-env": "^5.1.0", | ||
"cz-conventional-changelog": "^2.0.0", | ||
"istanbul": "^0.4.5", | ||
"lodash": "^4.17.4", | ||
"mocha": "^3.3.0", | ||
"nyc": "^10.3.2", | ||
"rollup": "^0.41.6", | ||
@@ -66,10 +58,6 @@ "rollup-plugin-alias": "^1.3.1", | ||
"rollup-plugin-sourcemaps": "^0.4.2", | ||
"semantic-release": "^6.3.2", | ||
"sinon": "^2.1.0", | ||
"sinon-chai": "^2.9.0", | ||
"source-map-support": "^0.4.15", | ||
"tslint": "^5.2.0", | ||
"typescript": "^3.3.1" | ||
}, | ||
"gitHead": "e2d64d60a7d47afc31f318140b91c8f33243a179" | ||
"gitHead": "2693898ea0eb80f21d25bfec8863df5ff5e4768c" | ||
} |
@@ -9,2 +9,3 @@ const path = require('path') | ||
// TODO: add Buffer shim | ||
const emptyshim = path.join(__dirname, 'dist/shims/empty.js') | ||
const debugshim = path.join(__dirname, 'dist/shims/debug.js') | ||
@@ -25,2 +26,7 @@ const fsshim = path.join(__dirname, 'dist/shims/fs.js') | ||
alias({ | ||
path: emptyshim, | ||
canvas: emptyshim, | ||
'face-api.js': emptyshim, | ||
'@tensorflow/tfjs-node': emptyshim, | ||
debug: debugshim, | ||
@@ -27,0 +33,0 @@ fs: fsshim, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
16901439
13
180
15788
9
5
7
+ Added@tensorflow/tfjs-node@^1.0.3
+ Addedface-api.js@^0.19.0
+ Added@eris/exif@0.3.1-alpha.10(transitive)
+ Added@tensorflow/tfjs@1.7.4(transitive)
+ Added@tensorflow/tfjs-converter@1.7.4(transitive)
+ Added@tensorflow/tfjs-core@1.0.31.7.4(transitive)
+ Added@tensorflow/tfjs-data@1.7.4(transitive)
+ Added@tensorflow/tfjs-layers@1.7.4(transitive)
+ Added@tensorflow/tfjs-node@1.7.4(transitive)
+ Added@types/node-fetch@2.6.12(transitive)
+ Added@types/offscreencanvas@2019.3.0(transitive)
+ Added@types/seedrandom@2.4.27(transitive)
+ Added@types/webgl-ext@0.0.30(transitive)
+ Added@types/webgl2@0.0.4(transitive)
+ Addedabbrev@1.1.1(transitive)
+ Addedadm-zip@0.4.16(transitive)
+ Addedagent-base@4.3.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedes6-promisify@5.0.0(transitive)
+ Addedface-api.js@0.19.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgoogle-protobuf@3.21.4(transitive)
+ Addedhttps-proxy-agent@2.2.4(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedignore-walk@3.0.4(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addedneedle@2.9.1(transitive)
+ Addednode-fetch@2.1.2(transitive)
+ Addednode-pre-gyp@0.14.0(transitive)
+ Addednopt@4.0.3(transitive)
+ Addednpm-bundled@1.1.2(transitive)
+ Addednpm-normalize-package-bin@1.0.1(transitive)
+ Addednpm-packlist@1.4.8(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedosenv@0.1.5(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedseedrandom@2.4.3(transitive)
+ Addedtfjs-image-recognition-base@0.5.1(transitive)
+ Addedtslib@1.14.1(transitive)
- Removed@eris/exif@0.3.1-alpha.9(transitive)
Updated@eris/exif@0.3.1-alpha.10