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

responsive-image-generator

v1.0.5

Published

A CLI tool to generate responsive image sizes and output HTML and React components.

Downloads

405

Readme

resize-images


A simple CLI tool to generate responsive image sizes from selected images.

This tool works on macOS and uses AppleScript and the sips command-line tool to resize images to specified dimensions.

Features

Select multiple images using a file picker. Resize images to 320px, 768px, and 1024px widths. Save resized images with the format <original_name>_.png in the same directory as the original file. Automatically open the directory containing the resized images after processing.

Requirements

macOS: This tool uses osascript (AppleScript) for file selection and sips for image resizing, both of which are macOS-specific utilities. Installation Install via npm

You can install responsive-image-generator globally using the following command:

npm install -g responsive-image-generator

Navigate to the Project Directory After installation, navigate to the directory where you want to run the tool.

Usage After installation, you can use the CLI tool with the following command:

resize-images

Steps

Run resize-images from your terminal.

A file picker will open, allowing you to select one or multiple images.

The tool will resize each selected image to three sizes: 320px, 768px, and 1024px. Resized images will be saved in the same directory as the originals, with the format <original_name>_.png.

After resizing, the tool automatically opens the directory containing the resized images.

resize-images

You will see output similar to this:

Resized to 320px: /path/to/image_320.png
Resized to 768px: /path/to/image_768.png
Resized to 1024px: /path/to/image_1024.png

Images resized successfully

Using the Generated Images in HTML and CSS

To make the most of the responsive images generated by this tool, you can use the following HTML and CSS examples.

HTML Example with srcset and sizes Attributes

<img
  src="/images/_320.png"
   srcset="
    /images/_320.png 320w,
    /images/_768.png 768w,
    /images/_1024.png 1024w
  "
  sizes="(min-width: 1024px) 1024px, (min-width: 600px) 768px, 100vw"
  alt="Responsive Image"
  class="responsive-image"
/>

CSS Example with Media Queries

You can also use CSS media queries to control the display size of the images based on the viewport:

/* Default style for small screens (mobile devices) */
.responsive-image {
  width: 100%;
  max-width: 320px;
}

/* Medium screen size: tablets */
@media (min-width: 600px) {
  .responsive-image {
    max-width: 768px;
  }
}

/* Large screen size: desktops */
@media (min-width: 1024px) {
  .responsive-image {
    max-width: 1024px;
  }
}

How It Works

The srcset attribute in HTML allows the browser to choose the best image size based on the viewport width: The sizes attribute specifies the conditions for each image size: (min-width: 1024px) 1024px: Uses the 1024px image for large screens. (min-width: 600px) 768px: Uses the 768px image for medium screens. 100vw: Uses 100% of the viewport width for smaller screens.

The CSS media queries provide a fallback to control the display size if srcset isn’t fully supported:


License

This package is licensed under the ISC License.