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

metalsmith-picset-generate

v0.0.2

Published

Generates image sets for use with metalsmith-picset-handlebars-helper to give browsers choice

Downloads

1

Readme

Generates image sets for use with metalsmith-picset-handlebars-helper to give browsers choice

Example use

Add to your pipeline like

npm i metalsmith-picset-generate --save
const picsetGenerate = require(metalsmith-picset-generate)
Metalsmith(__dirname)
	...
	.use(picsetGenerate())
	...

Under your source folder place an image /img/picset/picture_400,200,100w.jpg

It will build to appropriate formats / widths under /img/picset/

  • picture-100.jpg
  • picture-100.webp
  • picture-200.jpg
  • picture-200.webp
  • picture-400.jpg
  • picture-400.webp

Specification

Image types

Accepts .png and .jpg as input.

Outputs .webp and the input image type.

Image naming

Image size generation is done by naming convention with parameters denoted by the _{NUMBERS}{PARAM}. Examples:

Note: All examples will generate images with the name anthony at widths of 100px, 200px, and 400px

  1. anthony_400,200,100w.jpg - Name is anthony, file type is jpg
  2. anthony_400,200,100w_65jpg.jpg - Name is anthony, jpeg quality is 65%, file type is jpg
  3. anthony_400,200,100w_65jpg_50webp.jpg - Name is anthony, jpeg quality is 65%, webp quality is 50%, file type is jpg

Image naming: parameters

w - Image widths (Required)

Comma seperated list of integers for widths of output images

webp - .webp quality (Default: Set in plugin use() call or 80)

A integer from 1-100 indicating webp quality (lossy compression).

  • A value of 100 will trigger use of lossless compression mode

jpg - .jpg quality (Default: Set in plugin use() call or 80)

An integer from 1-100 indicating jpg quality (lossy compression).

Metalsmith options

Metalsmith options: Example object

{
	path: 'img/picset',
	jpg: 80,
	webp: 80
}

Which would place all images in img/picset with a default quality of 80 for both jpg and webp files

Metalsmith options: Specifics

path - images location (Default: img/picset/)

Place all your source images here. They should be high quality and high resolution.

  • Relative to Metalsmith source folder

jpg - Default jpg quality (Default: 80)

Default jpg quality if left unspecified in file name

webp - Default webp quality (Default: 80)

Default wbep quality if left unspecified in file name

Output

This plugin will generate images

  • In original format
  • In .webp format
  • At widths and qualities specified
  • At the specified path
  • Following a convention like {name}-{width}.{ext}
  • Removes original image

Background info

Recommendations

  • If you need optomized PNG output we recommended you add metalsmith-optipng to your pipeline.
  • Making a .png's dimensions smaller can sometimes increase filesize due to pecularities in the format's optomization methods and (we think) resizing can add additional pallet requirments. When making responsive .png files (and presumably lossless .webp files), review file sizes carefully.

Philosophy & architecture

  • Convention over Configuration
  • Image generation placed on file level instead of helper level
  • Generate once, use multiple times throughout site if desired
  • More likely to get cache hits by keeping standard file generation sizes on re-use
  • Seperate plugin for stages
  • Seperation of concerns (re-usable, if say someone wants to implement another templating engine solution than handlebars)
  • The Metalsmith way

Implementation

  • Uses sharp for image generation because sharp is fast
  • Implemented on Node v6.9.1, untested in other versions