Reputation: 19
I'm using Camanjs for image filtering, I have slider for increasing brightness. Everything works fine when I increase the value to slider which in turns increases the brightness, but now if I decrease the value back to 0, although it decreases the brightness but doesn't return the original image like before increasing the brightness.
eg:
Brightness -> 40 -> Displays image with increased Brightness
Brightness reduced back to zero
Brightness -> 0 -> Should display the image with zero brightness.
Similarly -> if I have applied blur and then contrast and then remove blur and contrast , i should get original image back.
It should work similar to : http://camanjs.com/examples/
My code:
slidderChangeHandler = (event, element) => {
event.persist();
let adjust = [...this.state.adjust];
adjust.map(el => {
if (el.name === element.name) {
el.range = event.target.value;
}
});
this.setState({ adjust: adjust }, () => {
let imgId = null;
if (
$(this.props.selected)
.attr("id")
.indexOf("text") > -1
) {
imgId =
"#" +
$(this.props.selected)
.children()
.attr("id");
} else {
imgId = "#" + $(this.props.selected).attr("id");
}
window.caman(imgId, function() {
this[element.name](parseFloat(event.target.value)).render()
});
});
};
I have tried using this.revert(true) before applying filter but that reset the canvas and previous filter are lost. Can anyone help me out here!!
Upvotes: 1
Views: 204