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

blurred

v2.0.0

Published

A fast image blur, based on [Stack Blur](http://incubator.quasimondo.com/processing/fast_blur_deluxe.php). It works directly on buffers, so can equally be used on the front and the back end.

Downloads

8,185

Readme

blurred

A fast image blur, based on Stack Blur. It works directly on buffers, so can equally be used on the front and the back end.

Get it:

npm install -s blurred

Gist

Basic usage:

import blur from 'blurred';

let buffer;
/*
 * Do something to initialise the image buffer.
 * Suppose the image buffer has width 1024, height 768.
 */

// blur the image with blur radius 12
const width = 1024;
const height = 768;
const blurRadius = 12;
blur(buffer, blurRadius, width, height);

Some convenience methods are provided in the browser:

import { blurCanvas, blurImage, blurURL } from 'blurred/util';

const blurRadius = 14;
// Blur an image located at a URL
blurURL('http://someurl', blurRadius)
  .then(image => {
    // do something with the image -- the argumant is an HTMLImageElement
  })
  .catch(err => {
    console.log('Error loading or blurring image.');
  });

// Blur an image located at a url, and set the document body background
// image to the result.
// For this, pass a second argument 'url'.
blurURL('http://someurl', blurRadius, 'url')
  .then(url => {
    document.body.style.backgroundImage = `url(${url})`;
  })
  .catch(err => {
    console.log('Error loading or blurring image.');
  });

// Blur an ImageElement in place
blurImage(someImageElement, blurRadius);

// Blur a region in a canvas in place.
const x = 12;
const y = 30;
const width = 46;
const height = 12;
blurCanvas(someCanvas, blurRadius, x, y, width, height);

blurred API

blur(pixels: Uint8ClampedArray, radius: number, width: number, height: number): Uint8ClampedArray

Blurs a buffer. Pixels are assumed four bytes long: three colour bytes and an alpha channel. The alpha channel is ignored in the blur. All number parameters must be integers, and the height is optional.

blurred/util – convenience functions in the browser

Some sugar around the basic blur.

blurCanvas(canvas: HTMLCanvasElement, radius: number, x, y, width: number, height: number): void

Blurs a rectangle in a canvas. The dimensions default to the size of the canvas.

blurImage(img: HTMLImageElement, radius: number, asImmutable?: boolean): HTMLImageElemen

Blurs an image. By default does so in place, but if the asImmutable option is set to true it does not modify the original. Returns the blurred image.

blurURL(url: string, radius: number, asDataURL?: boolean): Promise<HTMLImageElement|string>

Blurs an image at a given URL. Returns a promise that resolves to the blurred image, or a dataURL for that image, depending on whether the asDataURL flag is true.

Typescript

Everything is typed.

Changelog

  • 1.0.1 : very small bug fix. Blur height is calculated correctly.

  • 2.0.0 : API changes: all browser utilities are now in blurred/util. lib no longer exists. The basic blur function should be required directly from the package. See examples.

    Numerous typos in the documentation fixed. https://github.com/idokutela/blurred/pull/1 incorporated. The tsconfig was simplified, as was the packaging.

Copyright

The original implementation is Copyright (c) 2010 Mario Klingemann.

All modifications are Copyright (c) 2017 Alexander Kahle.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.