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

yair

v1.0.0

Published

A somewhat opinionated image resizer.

Downloads

2

Readme

Yet Another Image Resizer

A somewhat opinionated image resizer.

Installation

yarn install yair

Usage

import { resizeImage } from 'yair';

resizeImage(imgBuffer);

Resize options

The following resize options are available:

| URL Arg | Type | Description | |---|----|---| |w|Number|Max width of the image.| |h|Number|Max height of the image.| |quality|Number, 0-100|Image quality.| |resize|String, "w,h"|A comma separated string of the target width and height in pixels. Crops the image.| |crop_strategy|String, "smart", "entropy", "attention"|There are 3 automatic cropping strategies for use with resize: attention: good results, ~70% slowerentropy: mediocre results, ~30% slowersmart: best results, ~50% slower| |gravity|String|Alternative to crop_strategy. Crops are made from the center of the image by default, passing one of "north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest" or "center" will crop from that edge.| |fit|String, "w,h"|A comma separated string of the target maximum width and height. Does not crop the image.| |crop|Boolean|String, "x,y,w,h"|Crop an image by percentages x-offset, y-offset, width and height (x,y,w,h). Percentages are used so that you don’t need to recalculate the cropping when transforming the image in other ways such as resizing it. You can crop by pixel values too by appending px to the values. crop=160px,160px,788px,788px takes a 788 by 788 pixel square starting at 160 by 160.| |zoom|Number|Zooms the image by the specified amount for high DPI displays. zoom=2 produces an image twice the size specified in w, h, fit or resize. The quality is automatically reduced to keep file sizes roughly equivalent to the non-zoomed image unless the quality argument is passed.| |webp|Boolean, 1|Force WebP format.| |lb|String, "w,h"|Add letterboxing effect to images, by scaling them to width, height while maintaining the aspect ratio and filling the rest with black or background.| |background|String|Add background color via name (red) or hex value (%23ff0000). Don't forget to escape # as %23.|