Introduction
DarkroomJS is a JavaScript library which provides basic image editing tools in your browser, such as rotation or cropping. It is based on the awesome FabricJS library to handle images in HTML5 canvas.
Why?
It's easy to get a javascript script to crop an image in a web page. But if you want more features like rotation or brightness adjustment, then you will have to do all of this yourself. No more jQuery plugins here. DarkroomJS allows you to do whatever you want with your images by using the power of the HTML5 canvas.
The concept
The library is designed to be easily extendable. The core script only transforms the target image to a canvas with a FabricJS instance, and creates an empty toolbar. All the features are then implemented in separate plugins.
.
├── darkroom.js
└── plugins
├── darkroom.crop.js
├── darkroom.history.js
├── darkroom.rotate.js
└── darkroom.save.js
Each plugin is responsible for creating its own functionality. Buttons can easily be added to the toolbar and binded with those features.
Features
Currently, the implemented features are:
- Crop
- Crops the image by selecting a zone with your mouse. This supports several options like ratio and dimensions control (min/max).
- Rotation
- Adds two buttons to let you rotate the image left or right.
- History
- Allows you to undo and redo any changes you've made to the image.
- Save
- Transforms the canvas back into an image. This is mainly a proof of concept to show how plugins work. This plugin only takes a few lines.
Contributing
The project is released under the MIT license. Feel free to fork the project on GitHub or report issues. All ideas are also welcome.