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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bashbers/astro-image-dithering

v1.2.3

Published

Astro image dithering plugin - converts png's in project to dithered.pngs and uses them inside markdown files.

Readme

Astro image dithering plugin

demo gif

Why?

Want even quicker image loading times combined with a lower carbon footprint of serving your images? Use this plugin to dither your images before serving them to your audience! This decreases the image size dramatically whilst still providing your audience the context needed for your articles. If needed, endusers are able to ask for the original image using a button below the image.

For example:

original image

This image above is 29.07 kb.

dithered image

The dithered image above is 3.43 kb

A reduction of more than 8 times the initial size of the image without loss of context to the reader. The black and white palette is not that appealing, so the integration will provide a client-side filter using css which allows you to style the image to your theme like so:

Example in application

See the css-file and the .dithered class.

For more information about filter's hue-rotate property, read up on the documentation on mozilla.org. Find your color to use which matches your theme using this handy page.

Limitations

The current bayer dithering algorithm does not use the alpha channel of the png's provided. This causes transparent PNG's to look incorrect. A workaround is to only provide images with a solid color background (eg. white or black or any other color).

Guide

The astro integration can be used like this in your astro.config.mjs:

import { ditherImagesIntegration } from "@bashbers/astro-image-dithering";

export default defineConfig({
  integrations: [ditherImagesIntegration(
    {
      directoryToTraverse?: string; // Provide directory in which the plugin should search for images and dither them. By default looks inside your whole project.
      injectCss?: boolean; // Injects css which styles the figure, img and button for the images
      injectClientsideJs?: boolean; // Injects js which toggles the img between dithered and non-dithered
    }
  )],
});

How does it work?

The Astro integration will traverse your Astro directory searching for PNG files and convert them to dithered images using the -dithered.png suffix. They will be stored next to the original images. The dithering is done using a Bayer Dithering algorithm here. Inspiration is obtained from https://solar.lowtechmagazine.com/.

To make the integration work, it will provide a rehype container which replaces the with the corresponding figure, img and button for the dithered image. The source can be found here; The rehype plugin which will convert your existing image inclusions in your .md files to a figure containing both the image and a toggle to switch between the dithered and non-dithered version.

It will also by default inject css and js in your pages. The injected css is very slim and readable (if you ask me) and can be referenced in the css-file and the js-file The js file is a client-side script which will allow toggling between the dithered and non-dithered version of the image inside the container.

Custom css

If you want to apply custom css to the container, please set injectCss to false in the options of the integration and provide your own css file which applies styles to:

  • .dithered
  • .dithered-image-container
  • .dithered-button
  • .dithered-label

Future ideas

  • Expand image types to jpg, jpeg etc.
  • Support transparent PNGs
  • Support images next to markdown files.