draggable image annotation - Free Download Draggable Image Annotation Plugin - DragDropAnnotate

Free Download Draggable Image Annotation Plugin – DragDropAnnotate

Posted on

This time I will share jQuery Plugin and tutorial about Draggable Image Annotation Plugin – DragDropAnnotate, hope it will help you in programming stack.

draggable image annotation - Free Download Draggable Image Annotation Plugin - DragDropAnnotate
File Size: 410 KB
Views Total: 1635
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

DragDropAnnotate is a lightweight image annotation tool that make it easy to add custom markers, comments, hotspots to images via drag and drop.

Supports rectangle, rectangle, and image annotations. The drag and drop functionality based on jQuery UI draggable widget.

More Features:

  • Hint messages on mouse hover.
  • Popup window showing descriptions and tools of the annotation.
  • Custom annotation styles.
  • Allows to rotate the annotaion with mouse.
  • Licensed under the GPL-3.0.

How to use it:

1. Load the necessary jQuery and jQuery UI libraries in the document.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <script src="/path/to/cdn/jquery-ui.min.js"></script>

2. Load the latest Font Awesome 5 iconic font for the drag, rotate, trash, and hit icons (OPTIONAL).

1 <link rel="stylesheet" href="/path/to/cdn/fontawesome/all.css" />

3. Download and load the DragDropAnnotate plugin’s files in the document.

1 <link rel="stylesheet" href="./src/dragDropAnnotate.min.css" />
2 <script src="./src/dragDropAnnotate.min.js"></script>

4. Initialize the plugin on your image and we’re ready to go.

1 <img id="imageExample" src="example.jpg" />
1 var anno = $("#imageExample").annotable({
2     // optional settings here
3 });

5. Add a custom annotation to the image using the addAnnotation(myAnnotation, annotationReplaced) method. The second parameter is used to decide whether to replace the existing annotations.

1 <img id="imageExample" src="example.jpg" />
01 anno.addAnnotation({
02  
03   // Unique ID
04   // OPTIONAL
05   id: "1",
06  
07   // path to the image annotation
08   // OPTIONAL
10  
11   // Description of the annotation
12   text: "My annotation",
13  
14   // "disabled", "noText", "full"
15   editable: "noText",
16  
17   // Position of the annotation
18   position: {
19     center: { x: 0, y: 0 }
20   },
21  
22   // Rotation of the annotation with respect to the x-axis (degrees).
23   // OPTIONAL
24   rotation: 0,
25  
26   // Width/height of the annotation
27   // OPTIONAL
28   width: 123,
29   height: 123
30  
31 });

6. Or create custom annotations that you can place on the images via drag and drop.

01 <h2>Drag and Drop an annotation to Annotate</h2>
02  
03 <div class="draggable-annotation"
04      annotation-text="Rectangle Annotation"
05      annotation-width="200"
06      annotation-height="400"
07      annotation-rotation="0"
08      annotation-id="1"
09      annotation-editable="full">
10      Rectangle Annotation
11 </div>
12  
13 <img class="annotation"
14      src="2.jpg"
15      annotation-text="Image Annotation"
16 />

7. Override the default CSS select of draggable annotations.

1 var anno = $("#imageExample").annotable({
2     "draggable": ".draggable-annotation"
3 });

8. Customize the hint.

01 var anno = $("#imageExample").annotable({
02     "hint": {
03       "enabled": true,
04       "message": "Drag and Drop to Annotate",
05       "icon": '<i class="far fa-question-circle"></i>',
06       "messageMove": "Move to set new annotation position",
07       "iconMove": '<i class="fas fa-info"></i>',
08       "messageRotate": "Move to set new annotation rotation",
09       "iconRotate": '<i class="fas fa-info"></i>',
10     },
11 });

9. Customize the popup window.

01 var anno = $("#imageExample").annotable({
02     "popup": {
03       "buttonMove": '<i class="fas fa-arrows-alt"></i>',
04       "tooltipMove": "Change the position of annotation",
05       "buttonRotate": '<i class="fas fa-sync-alt"></i>',
06       "tooltipRotate": "Change the rotation of annotation",
07       "buttonRemove": '<i class="fas fa-trash"></i>',
08       "tooltipRemove": "Remove the annotation",
09       "tooltipText": "Text of annotation"
10     },
11 });

10. Customize the annotation styles.

1 var anno = $("#imageExample").annotable({
2     "annotationStyle": {
3       "borderColor": '#ffffff',
4       "borderSize": 2,
5       "hiBorderColor": '#fff000',
6       "hiBorderSize": 2.2,   
7       "imageBorder": true
8     }
9 });

11. Publish methods.

01 // Returns an array of annotations.
02 ano.getAnnotations();
03  
04 // Removes an annotation.
05 ano.removeAnnotation(annotation)
06