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

comp-img

v1.3.0

Published

A command-line tool for compressing large quantities of images. Also has the ability to quickly compress a single image. This tool removes the dependency on other similar tools like TinyPNG to accomplish these tasks and is free.

Downloads

4

Readme

img-compressor (comp)

A command-line tool for compressing large quantities of images. Also has the ability to quickly compress a single image. This tool removes the dependency on other similar tools like TinyPNG to accomplish these tasks and is free. Uses the jpegoptim and pngquant open-source image compression libraries.

Installation

npm i jpegoptim-bin npm i pngquant-bin npm i -g comp-img

Usage

Compressing large quantities of images

  • "cd" into the project's directory
    • cd ~/Desktop/example-project
  • Run comp
    • Example usage:
      • comp start
      • comp start -i "imgs"
      • comp start -i "imgs" -o "comp-imgs"
      • comp start --input "imgs"
      • comp start --input "imgs" --output "comp-imgs"
      • comp start -e "folder1 folder2/sub2" -v
      • comp start --except "folder1 folder2/sub2" --verbose
    • The -i or --input option allows you to specify where the uncompressed images can be found
      • By default the tool assumes your input directory is ./img. If this is not the case use the following command:
        • comp start -i "imgs"
        • comp start --input "imgs"
    • The -o or --output option allows you to specify where the compressed images should be found
      • By default the tool will put the compressed images in ./comp. If you would like the images placed elsewhere, use the following command
        • comp start -o "comp-imgs"
        • comp start --output "comps"
    • This tool has the ability to exclude a directory of images (and all of the subdirectories inside the excluded directories) from compression completely. This option might be useful if you have a specific folder or folders inside your input directory that are very large will slow down processing/compression time considerably if not excluded
      • Folder paths can either be relative or absolute, but preferably relative. Separate multiple folder names with a space or comma
      • comp start -e "folder1 folder2/sub3"
      • comp start -e "folder1,folder2/sub3"
      • comp start --except "folder1 folder2/sub3"
      • comp start --except "folder1,folder2/sub3"
    • During compression the -v or --verbose options give you the ability to see the file path of every file logged to the terminal before it is compressed. Since this tool was designed to compress a large number of images at once, this could quite a lot of output, so this option is disabled by default.
      • comp start
        • Only output the file path of files that are not .jpg, .jpeg or .png images
      • comp start -v or comp start --verbose
        • Will output the file path both the skipped non-image files (i.e. the files that don't end in .jpg, .jpeg or .png) as well as the file path of each image before it is compressed.
      • Useful for debugging purposes to see exactly what images the tool compressed.
    • All options can be chained together
      • comp start --input "imgs" --output "comp-imgs"
      • comp start -i "imgs" -o "comp-imgs"
      • comp start -i "uncomp" -o "imgs" -e "folder1 folder2/sub2"
      • comp start -e "folder1 folder2/sub2" -v
      • comp start --except "folder1 folder2/sub2" --verbose

Quickly compress a single image

  • "cd" into the directory that has the image you want to compress
    • cd ~/Desktop
  • Run comp on that single image
    • comp example-image.png
    • comp folder one/img.jpeg
    • comp ~/Desktop/the-folder/image.jpg

Known issues

  • When compressing images smaller than 1 KB the compressed image is slightly larger in file size than the original image
  • When running comp start initially, an error is thrown for the .jpgs and .jpegs in the root directory and the images are not compressed, after running comp start a second time, no error is thrown and the .jpgs and .jpegs in root directory are compressed like they should be (doesn't happen all the time)
    • If this occurs re-run comp start with the same options as you had before, this usually fixes this issue.
    • This issue doesn't occur ever time
  • Folder names with spaces in them sometimes unexpectedly cause errors to occur during compression

Feature wish list for future versions

  • More descriptive output when actual compression is taking place that states how much file size was saved by compressing the image
  • Perhaps a progress bar for when compressing large quantities of images
  • Add ability to customize compression level (from 0 - 100) for images (currently 85)