This is a simple project to enable you crop multiple images in a folder which have the same dimensions.
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.
- You need Node installed in your environment
- npm packages required: express, sharp, morgan-body and nodemon (for dev auto-restart)
- Clone the repo or download from this repo.
- Copy to a directory in your computer.
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.
Follow the Github link for more info about node-windows.
- 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.
On your browser window, you will get the below output:
On the console, you will get the below output:
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. DONEBetter error handlingOrganize the project better with folders etc.Additional functionality:Start and stop the application processingChoose the path. Directory picker browser support is scanty for now. Implement later.Choose whether to delete the original files etc.
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.
-
1.0.0
- Initial release
- See commit change
-
1.1.0
- Added front-end features
-
1.2.0
- Added Windows Service Feature
This project is licensed under the MIT License.
Inspiration, code snippets, etc.