1.3.0 • Published 7 years ago

comp-img v1.3.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
7 years ago

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)
1.3.0

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago