darkroom

WebJar for darkroom

License

License

MIT
Categories

Categories

Github Development Tools Version Controls
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

github-com-mattketmo-darkroomjs
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

darkroom
WebJar for darkroom
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mattketmo/darkroomjs

Download github-com-mattketmo-darkroomjs

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-mattketmo-darkroomjs/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-mattketmo-darkroomjs</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-mattketmo-darkroomjs/
implementation 'org.webjars.npm:github-com-mattketmo-darkroomjs:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-mattketmo-darkroomjs/
implementation ("org.webjars.npm:github-com-mattketmo-darkroomjs:2.0.0")
'org.webjars.npm:github-com-mattketmo-darkroomjs:jar:2.0.0'
<dependency org="org.webjars.npm" name="github-com-mattketmo-darkroomjs" rev="2.0.0">
  <artifact name="github-com-mattketmo-darkroomjs" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-mattketmo-darkroomjs', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "github-com-mattketmo-darkroomjs" % "2.0.0"
[org.webjars.npm/github-com-mattketmo-darkroomjs "2.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

DarkroomJS

License MIT

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.

Demo

Try the online demo at http://mattketmo.github.io/darkroomjs

WARNING

This library is no longer maintained. If you're looking for an alternative you can check out Doka Image Editor. It supports every DarkroomJS feature and much more (like resizing, free rotating, color adjustment, photo filters, annotating, etc).

Doka Image Editor demo

Building

  • Install Node & npm.
  • Run npm install to build dependencies.
  • Run npm start to build the assets and start the demo webserver.

Usage

Simply instanciate a new Darkroom object with a reference to the image element:

<img src="some-image.jpg" id="target">
<script>
  new Darkroom('#target');
</script>

You can also pass some options:

new Darkroom('#target', {
  // Canvas initialization size
  minWidth: 100,
  minHeight: 100,
  maxWidth: 500,
  maxHeight: 500,

  // Plugins options
  plugins: {
    crop: {
      minHeight: 50,
      minWidth: 50,
      ratio: 1
    },
    save: false // disable plugin
  },

  // Post initialization method
  initialize: function() {
    // Active crop selection
    this.plugins['crop'].requireFocus();

    // Add custom listener
    this.addEventListener('core:transformation', function() { /* ... */ });
  }
});

Why?

It's easy to get a javascript script to crop an image in a web page. But if your want more features like rotation or brightness adjustment, then you will have to do it yourself. No more jQuery plugins here. It only uses the power of HTML5 canvas to make what ever you want with your image.

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.

Each plugin is responsible for creating its own functionality. Buttons can easily be added to the toolbar and binded with those features.

Contributing

Run npm develop to build and watch the files while developing.

FAQ

How can I access the edited image?

In order to get the edited image data, you must ask the canvas for it. By doing so inside the callback of your choice (in this case save), you can assign the edited image data to wherever you please.

save: {
      callback: function() {
          this.darkroom.selfDestroy(); // Cleanup
          var newImage = dkrm.canvas.toDataURL();
          fileStorageLocation = newImage;
      }
  }

License

DarkroomJS is released under the MIT License. See the bundled LICENSE file for details.

Versions

Version
2.0.0