Introduction
29 | 30 |31 | DarkroomJS is a JavaScript library which provides basic 32 | image editing tools in your browser, such as rotation or cropping. 33 | It is based on the awesome FabricJS library 34 | to handle images in HTML5 canvas. 35 |
36 | 37 |
Why?
53 | 54 |55 | It's easy to get a 56 | javascript script to crop an image in a web page. But if you want 57 | more features like rotation or brightness adjustment, then you will have to do all of this yourself. 58 | No more jQuery plugins here. DarkroomJS allows you to do whatever you want with your images by 59 | using the power of the HTML5 canvas. 60 |
61 | 62 |The concept
63 | 64 |65 | The library is designed to be easily extendable. 66 | The core script only transforms the target image to a canvas with a 67 | FabricJS instance, and creates an empty toolbar. 68 | All the features are then implemented in separate plugins. 69 |
70 | 71 |.
73 | ├── darkroom.js
74 | └── plugins
75 | ├── darkroom.crop.js
76 | ├── darkroom.history.js
77 | ├── darkroom.rotate.js
78 | └── darkroom.save.js
79 | 82 | Each plugin is responsible for creating its own functionality. 83 | Buttons can easily be added to the toolbar and binded with those features. 84 |
85 | 86 |Features
87 | 88 |89 | Currently, the implemented features are: 90 |
91 | 92 |-
93 |
- Crop 94 |
- 95 | Crops the image by selecting a zone with your mouse. 96 | This supports several options like ratio and dimensions control (min/max). 97 | 98 | 99 |
- Rotation 100 |
- 101 | Adds two buttons to let you rotate the image left or right. 102 | 103 | 104 |
- History 105 |
- 106 | Allows you to undo and redo any changes you've made to the image. 107 | 108 | 109 |
- Save 110 |
- 111 | Transforms the canvas back into an image. 112 | This is mainly a proof of concept to show how plugins work. 113 | This plugin only takes a few lines. 114 | 115 |
Contributing
123 | 124 |125 | The project is released under the MIT license. 126 | Feel free to fork the project on GitHub 127 | or report issues. All ideas are also welcome. 128 |
129 | 130 |