Coder Social home page Coder Social logo

imagecompressor's Introduction

ImageCompressor

ImageCompressor is a tiny Node service I use to compress any screenshots uploaded to my server.

It is a simple CLI that watches a directory for any new image files, and compresses them if applicable.

ImageCompressor supports 4 main file types:

  1. PNG
  2. JPEG
  3. SVG
  4. GIF

and uses compress-images to handle image compression.

Functionality

ImageCompressor was built with a specific requirement set: Watch a directory for new images that will be uploaded via SFTP, and compress them automatically

From testing, this is achieved well. Checks are done to respect the updating of files as they upload, and the tool performs well, with absolutely no blocking code (all work is done asynchronously via callbacks).

Images are compressed effectively, with an average size reduction of ~60% (although this is not an achievement of ImageCompressor, moreso the compression tools made by talented developers)

ImageCompressor is also lightweight, with very few NPM dependencies.

Usage

Using ImageCompressor is trivial:

npm start - starts ImageCompressor watching the working directory

npm start --directory=/some/dir/here - Starts ImageCompressor watching a given directory

npm run debug [--directory] - Starts ImageCompressor in debug mode. More logging info will be given.

Directories

ImageCompressor uses 3 main directories:

  1. The watched directory. This defaults to the working directory or can be specified as shown above.
  2. The logs directory. All logs are piped to here via the start script, into either info.log or error.log. Pino is used for pretty log messages (however colours may not display properly in a file).
  3. The .build directory. This is a hidden directory used to store compressed copies of images. Once compression completes, these copies are removed.

Future Plans and Feedback

  • Store uncompressed images?
  • Improve the logging, writing to both a file and stdout
  • Clean up the code, split into separate files, etc

I am not overly familiar with JavaScript and Node, so some conventions may have been broken here. Feedback is appreciated and any PRs are very welcome!

imagecompressor's People

Contributors

bristermitten avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.