New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eris/image

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eris/image - npm Package Compare versions

Comparing version 0.3.1-alpha.9 to 0.3.1-alpha.10

data/models/face_expression_model-shard1

9

dist/analyses/sharpness.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc