GithubHelp home page GithubHelp logo

munenendereba / node-batch-image-cropper Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 128 KB

Using sharp library to batch-crop images with the same dimensions.

JavaScript 57.60% CSS 8.16% EJS 34.23%
crop image sharp node-windows nodejs

node-batch-image-cropper's Introduction

Batch Image Cropper on Node.js with sharp package

This is a simple project to enable you crop multiple images in a folder which have the same dimensions.

Description

Crop all those screenshots which to remove some portions such as identifiable info on your computer screen before sharing publicly. This uses the sharp package. This is part of my learning Node and I wanted to experiment.

Getting Started

Dependencies

  • You need Node installed in your environment
  • npm packages required: express, sharp, morgan-body and nodemon (for dev auto-restart)

Installing

  • Clone the repo or download from this repo.
  • Copy to a directory in your computer.

Installing as a Windows Service

Thanks to the great package node-windows, we can run this as a Windows Service that is installed on services.msc and can behave like a normal windows service.

Run the command node install.js to install and node uninstall.js to uninstall the service. It will appear as below once installed.

Batch Image Cropper Windows Service

Follow the Github link for more info about node-windows.

Executing program

  • Install all the dependencies as shown above by running commands below
npm init -y

If any dependency is not installed, you can install as below:

- npm install express sharp morgan-body
- npm install --save-dev nodemon

Start the application using the normal npm commands:

npm start

On the browser, navigate to http://localhost:3031/ and input the parameters as shown below and click "Start cropping..." button.

Image Parameters

On your browser window, you will get the below output:

Cropping Complete

On the console, you will get the below output:

Processing images

Improvements

The project needs to improve in the following:

  • Connect to a front-end (React) for input of the parameters such as path, image cropping dimensions etc. DONE
  • Better error handling
  • Organize the project better with folders etc.
  • Additional functionality:
    • Start and stop the application processing
    • Choose the path. Directory picker browser support is scanty for now. Implement later.
    • Choose whether to delete the original files etc.

Help

If you get errors when processing, check the following:

  • The image path exists
  • The dimensions are correct. I used MS Paint to determine the start and the dimensions of the cropped image.

Authors

Munene Isaka

Version History

  • 1.0.0

  • 1.1.0

    • Added front-end features
  • 1.2.0

    • Added Windows Service Feature

License

This project is licensed under the MIT License.

Acknowledgments

Inspiration, code snippets, etc.

node-batch-image-cropper's People

Contributors

munenendereba avatar

Watchers

 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.