[]
        
(Showing Draft Content)

ImageFiltersPlugin

Class: ImageFiltersPlugin

ImageFiltersPlugin class. Adds the "Image Filters" button.

Example

<script src="gcimageviewer.js"></script></head>
<script src="plugins/imageFilters.js"></script>
<script>
  var viewer = new GcImageViewer("#root");
  viewer.addPlugin(new ImageFiltersPlugin());
</script>

Param

Extends

  • ImageViewerPluginBase

Constructors

Constructor

new ImageFiltersPlugin(options?): ImageFiltersPlugin;

ImageFiltersPlugin constructor.

Parameters

options?

ImageFiltersPluginOptions

plugin options

Returns

ImageFiltersPlugin

Overrides

ImageViewerPluginBase.constructor

Properties

id

readonly id: PluginType;

Unique plugin identifier.

Overrides

ImageViewerPluginBase.id

options

options: ImageFiltersPluginOptions;

Plugin options

Accessors

filters

Get Signature

get filters(): object;

Gets available image filters.

Example
// Create Image Filters plugin:
const imageFiltersPlugin = new ImageFiltersPlugin();
// Remove the default image filters, except for the "Invert" filter:
const filters = imageFiltersPlugin.filters;
for(const filterName in filters) {
	if(filterName === "invert")
		continue;
	delete filters[filterName];
}
// Add custom Image Filter:
filters["lemon-effect"] = {
   filterId: "lemon-effect",
   toolbarKey: "lemon-effect",
   title: "Apply Custom Lemon effect",
   text: "Apply Lemon effect",
   action: function(imageData) {
       for (i = 0; i < imageData.data.length; i += 4) {
          imageData.data[i + 1] = imageData.data[i] + 45; // increase green component
       }
       return imageData;
   }
};
// Register Image Filters plugin:
viewer.addPlugin(imageFiltersPlugin);
Returns

object


in17n

Get Signature

get in17n(): i18n;

Gets the internationalization (i18n) instance from the viewer.

Returns

i18n

The i18n instance.

Overrides

ImageViewerPluginBase.in17n

isReady

Get Signature

get isReady(): boolean;

Returns true if the image is loaded into the viewer and the image format is supported by the Image Filters plugin.

Returns

boolean

Overrides

ImageViewerPluginBase.isReady

naturalSize

Get Signature

get naturalSize(): object;

Natural image size.

Returns

object

height
height: number;
width
width: number;

Overrides

ImageViewerPluginBase.naturalSize

paintLayer

Get Signature

get paintLayer(): IImageLayer;

Gets the paint layer containing the HTML canvas for drawing the image.

Returns

IImageLayer

Inherited from

ImageViewerPluginBase.paintLayer

viewer

Get Signature

get viewer(): IImageViewer;

Gets the image viewer instance.

Returns

IImageViewer

The image viewer instance.

Overrides

ImageViewerPluginBase.viewer

Methods

applyFilter()

applyFilter(filterName, intensity?): Promise<boolean>;

Apply image filter.

Parameters

filterName

string

intensity?

number

Returns

Promise<boolean>


cancelChanges()

cancelChanges(): boolean | void | Promise<boolean | void>;

Called when parent viewer requests cancel changes, usually when the ESCAPE key is pressed.

Returns

boolean | void | Promise<boolean | void>


confirmChanges()

confirmChanges(): boolean | void | Promise<boolean | void>;

Called when parent viewer requests confirm and apply changes, usually when the Ctrl+Enter or Enter key is pressed.

Returns

boolean | void | Promise<boolean | void>


dispose()

dispose(): void;

Cleans up resources and disposes the plugin.

Returns

void

Overrides

ImageViewerPluginBase.dispose

initialize()

initialize(viewer): void;

Initializes the plugin with the given image viewer.

Parameters

viewer

any

The image viewer instance to associate with this plugin.

Returns

void

Overrides

ImageViewerPluginBase.initialize

isImageFormatSupported()

isImageFormatSupported(imageFormat, allowUnknown?): boolean;

Checks if the image format specified by the imageFormat parameter is supported.

Parameters

imageFormat

string | ImageFormatCode

allowUnknown?

boolean

Returns

boolean

Overrides

ImageViewerPluginBase.isImageFormatSupported

redoTransactionStep()

redoTransactionStep(): boolean | void;

Redo viewer transaction step. Return true if redo operation is consumed.

Returns

boolean | void


removePaintLayer()

removePaintLayer(): void;

Removes and disposes the active paint layer. If no paint layer exists, this method does nothing.

Returns

void

Inherited from

ImageViewerPluginBase.removePaintLayer

undoTransactionStep()

undoTransactionStep(): boolean | void;

Undo viewer transaction step. Return true if undo operation is consumed.

Returns

boolean | void