npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

magic-erase

v0.0.2

Published

Clear blurry background in small close-focused images

Downloads

8

Readme

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

Name|Image|AfterErasing|Sensitivity -|-|-|- Baseball|||12.2 Birb|||77.9 Cherry|||55 Mic|||14.9 Sunflower|||67.3 Flower|||0.1