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

webpify

v1.0.3

Published

Converts images to WebP & replace non-WebP image references in HTML and CSS files

Downloads

15

Readme

Webpify

Converts images to WebP format and replaces non-WebP image references in HTML and CSS files.

Description

Webpify is a command-line tool that allows you to convert images to the WebP format. It provides two main functionalities:

  1. Image Conversion: Converts images (JPEG, PNG, and GIF) to WebP format, reducing file size while maintaining image quality.
  2. Image Reference Replacement: Replaces non-WebP image references in HTML and CSS files with their WebP equivalents, ensuring optimal performance on the web.

Features

  • Converts images (JPEG, PNG, and GIF) to WebP format.
  • Replaces non-WebP image references in HTML and CSS files with WebP equivalents.
  • Provides command-line interface for easy execution and integration into build processes.
  • Preserves image quality while significantly reducing file size.
  • Supports bulk image conversion and reference replacement.
  • Works with both local and remote file paths.

Installation

To use Webpify, you need to have Node.js installed on your machine. Once Node.js is installed, you can install the package globally using npm:

npm install -g webpify

Usage

The package provides a command-line interface (CLI) to perform image conversion and reference replacement.

Image Conversion

To convert images to WebP format, use the following command:

webpify --src <source_directory> --dest <destination_directory> [-q <quality>]
  • <source_directory>: The directory containing the images to be converted.
  • <destination_directory>: The directory where the converted WebP images will be saved.
  • <-q <quality>: (optional): The quality of the converted images. The default quality is 85. Specify a value between 1 and 100.

This command converts all images (JPEG, PNG, and GIF) in the source directory to WebP format and saves them in the destination directory with the specified quality.

Image Reference Replacement

To replace non-WebP image references in HTML and CSS files with their WebP equivalents, use the following command:

webpify --src <source_directory> --dest <destination_directory> --replace
  • <source_directory>: The directory containing the HTML and CSS files with image references.
  • <destination_directory>: The directory where the converted WebP images are stored.
  • --replace: Optional flag to indicate that image references should be replaced.

This command scans all HTML and CSS files in the source directory, finds non-WebP image references, and replaces them with their WebP equivalents. The modified files are saved in the same location.

Note: The --replace flag is optional. If not provided, the image references will not be replaced.

Examples

Image Conversion Example

Convert all images in the images directory to WebP format and save them in the converted directory:

webpify --src images --dest converted

Image Reference Replacement Example

Convert images in the images directory to WebP format and replace image references in HTML and CSS files in the src directory:

webpify --src src --dest images --replace

Dependencies

Webpify relies on the following dependencies:

  • glob: ^8.1.0
  • webp-converter: ^2.3.0
  • yargs: ^17.0.1

These dependencies will be automatically installed when you install the package.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on GitHub.

Credits

Webpify was created by Angelos Barmpoutis.