

LenaJS.redrawCanvas(filteredImageCanvas, secondFilter) Apply the second filter (with the first filter that has been already applied) Second filter to apply in this case the invert This method expects as first argument the canvas where an image with a filter has been already rendered and as second argument the new filter that will be appended to the image: So if you want to apply a filter after another, you will need to use the redrawCanvas method instead. Applying multiple filtersĪs mentioned, the filterImage method applys a single filter to an image, however if you execute it again, the start filter will be removed.

You can lastly export the image with the applied filter by simply getting its base64 representation with the filteredImageCanvas.toDataURL("image/png") method. LenaJS.filterImage(filteredImageCanvas, filter, originalImage) Filter to apply, in this case the red filter Var filteredImageCanvas = document.getElementById("filtered-image") The canvas where the processed image will be rendered (With filter) Var originalImage = document.getElementById("original-image") The image can be either a file loaded through src or as data URI base64: This method expects as first argument the canvas where the image with filter should be rendered, as second argument the filter (as a constant) that will be applied and as last argument the IMG element that stores the image. The magic happens with the LenaJS.filterImage method. Those properties are functions, however they are not used directly as a function by you but for LenaJS as a "constant". The filters are stored in the same global variable LenaJS and can be accessed through its id using the key or dot notation e.g LenaJS or LenaJS.prewittHorizontal. The following list shows the ID of every filter: Lena.js offers a variety of filters that can be applied to your image. Those methods expects an image and a canvas that will be used to apply some filter: Available filters LenaJS is pretty easy to use, you can use 2 methods namely filterImage and redrawCanvas.
#Myspace filters for photos install
You can download the copy from the repository at Github here or by using some package manager like bower: bower install lena.jsįor more information about this library, please visit the official repository at Github here. You can include a local copy of Lena.js from your project or use the CDN or from a local copy: It allows you to apply some basic image filters to an image in the document. Lena.js is a tiny library for image processing.
#Myspace filters for photos how to
In this article we'll show you how to add some image filters to images in the browser using the Lena.js library. Although JavaScript isn't suitable for Image manipulation at least for huge scale, it can be used with not so heavy images in the browser and in little projects.

The image filtering allows you to apply various effects on photos.
