Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

magic-erase

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magic-erase

Clear blurry background in small close-focused images

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

npm javascript style guide

Clear blurry background in close-focused images, by selecting click-points on the image. Works like the magic-wand tool in Photoshopp.

Installation

npm install magic-erase

Usage

var magicErase = require('magic-erase')

Configuration

// Tweak the Sensitivity for optimal result

var config = {
  image: 'path-to-image', // JPG format and preferrably less than 100 kB
  sensitivity: 50, // ranges from 0.1 to 100,
  erasePoints: [
     // a list of points on the image which will be used as the click points
     // each point is <x-coordinate, y-coordinate>
     // x-coordinate is from left to right
     // y-coordinate is from top to bottom
     // coordinates are normalized within the range 0 to 100 (i.e. percentage)
    [45, 86], [87, 12], [9, 56]
  ]
}

API

var fs = require('fs')

var firstPass = magicErase(config).then(function (response) {
  // save erased result as image file ...
  var base64Img = response.base64Img
  fs.writeFile('output-image.jpg', base64Img, { encoding: 'base64' }, function() {
  	console.log('Saved output image')
  })
  // use the erased result data for a second erase pass
  var data = response.data
  return data
})
var secondPass = firstPass.then(function(response) {
  var newConfig = {
    image: response,
    sensitivity: 48,
    erasePoints: [[8, 4], [65, 12]]
  }
  return magicErase(newConfig)
}).then(function(response) {
  // just like in the first pass
  var base64Img = response.base64Img
  // use base64Img ...
  return response.data
})

// .. do as many passes as you like ...

Caution

  • Bigger images will take longer time

Web console

magic-erase-console is a simple web console for the magic-erase package.

Examples

NameImageAfterErasingSensitivity
Baseball12.2
Birb77.9
Cherry55
Mic14.9
Sunflower67.3
Flower0.1

Keywords

FAQs

Package last updated on 01 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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