3.0.0 • Published 4 months ago

@eqproject/eqp-img-drawing v3.0.0

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

Table of contents

Getting started

This component allows to draw on pictures and export the result as a Blob. Is is based on the use of fabric.js.

Step 1: Install eqp-attachments and fabric:

npm install --save @eqproject/eqp-img-drawing
npm install fabric@3.6.2

Step 2:

Import the EqpImgDrawingModule:

import { EqpImgDrawingModule } from '@eqproject/eqp-img-drawing';

@NgModule({
  declarations: [AppComponent],
  imports: [EqpImgDrawingModule],
  bootstrap: [AppComponent]
})
export class AppModule {}

API

Inputs

InputTypeDefaultRequiredDescription
srcstringnullyesImage url or base64 string
i18nI18nInterface?'I18nEn'noText labels to use
outputMimeTypestring?nullnoMime type of the output image
outputQualitynumber?nullnoNumber between 0 and 1 to determine the quality of the ouput image
loadingTemplateTemplateRef<any>?nullnoTemplate shown while loading
errorTemplateTemplateRef<any>?nullnoTemplate shown in case of error
enableTooltipboolean?falsenoEnable/disable tooltip for toolbar buttons/actions
tooltipLanguagestring?'en'noLanguage of tooltip (en or fr)
widthnumber?nullYes if no src providedWidth of the canvas
heightnumber?nullYes if no src providedHeight of the canvas
forceSizeCanvasbooleantruenoForce the canvas to width and height of image or with those specified
forceSizeExportbooleanfalsenoForce the exported image to width and height with those specified
borderCssstring?'none'noAdd a border to the canvas in CSS (example: 1px solib black)
enableRemoveImagebooleanfalsenoEnable the option to remove the image loaded
enableLoadAnotherImagebooleanfalsenoEnable the option to load another image
showCancelButtonbooleantruenoEnable the cancel button
colors{ [name: string]: string }{ black: '#000', white: '#fff', yellow: '#ffeb3b', red: '#f44336', blue: '#2196f3', green: '#4caf50', purple: '#7a08af' }noColors available for users
drawingSizes{ [key: string]: number }?{ small: 5, medium: 10, large: 25 }noSizes available for users

Outputs

OutputEvent ArgumentsRequiredDescription
(save)EventEmitter<Blob>noInvoked on save button click, use $event to get the Blob of the new edited image
(cancel)EventEmitter<void>noInvoked on cancel button click

Use cases

<eqp-img-drawing [showCancelButton]="false" [enableLoadAnotherImage]="true" [enableRemoveImage]="true"
    [src]="src" (save)="saveBtn($event)" [i18n]="i18n" [locale]="locale" 
    [drawingSizes]="{ small: 5, medium: 10, large: 25, extra: 50 }">
</eqp-img-drawing>
    import { I18nInterface } from 'projects/eqp-img-drawing/src/public-api';
    
    ...
    
    i18n: I18nInterface = {
        saveBtn: 'Salva immagine',
        sizes: {
            extra: 'Extra'
        }
    };
    src: string = 'https://images.unsplash.com/photo-1565199953730-2ea3b119ae22?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=700&q=80';
   
   ...
   
    saveBtn(event) {
        console.log(event)
    }

Credits

This library has been developed by EqProject SRL, for more info contact: info@eqproject.it

2.5.1

4 months ago

3.0.0

4 months ago

2.5.0

4 months ago

2.0.4

4 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago