9

If I have an image that I apply a filter to, e.g. Lomo filter, is there way to make that the current Caman instance?

Meaning, if I then want to then play about with the brightness on the image that I applied the filter to, and use this.revert(); to reset the brightness, I want it to revert to the canvas with the filter on it that I just applied.

Is this possible?

I'm having a nightmare with trying to apply many effects, only one at once (except for preset filters), and carry the state through...

Kara
  • 6,115
  • 16
  • 50
  • 57
StudioTime
  • 22,603
  • 38
  • 120
  • 207

2 Answers2

1

If i understand, you want to apply filter ("Lomo") as shown on their example page and then fiddle with some properties (like brightness) and then revert changes back to "Lomo" filter?

Why not just click on filter ("Lomo") again?

EDIT: You should probably take a look at guide and implement your own method with default values like in filters.

u.Filter.register("lomo", function (D) {
        if (D == null) {
            D = true
        }
        this.brightness(15);
        this.exposure(15);
        this.curves("rgb", [0, 0], [200, 0], [155, 255], [255, 255]);
        this.saturation(-20);
        this.gamma(1.8);
        if (D) {
            this.vignette("50%", 60)
        }
        return this.brightness(5)
    });

I dont think your requirement comes "out of the box".

terafor
  • 1,620
  • 21
  • 28
  • 1
    No, I want to apply ("Lomo") filter and then maybe add some brightness and then some contrast on top of the filter. After each change e.g. brightness (I might choose to add brightness value 10 but that's not enough, so decide 15 would be better), to save it adding it exponentially, it reverts back to the original instance (in this example to avoid adding 15 to an image already with 10, also, adding 10 then adding -10 is not the same as not adding at all). This destroys any changes, e.g. the ("Lomo") filter settings. – StudioTime Jun 10 '13 at 09:50
  • 1
    At the moment I'm swapping out a temp image each time I apply something that might be added to, but its cumbersome and hardly efficient. Hope that makes sense – StudioTime Jun 10 '13 at 09:54
  • Probably best thing to do is to implement your own method and twerk properties inside. – terafor Jun 10 '13 at 12:20
  • Thanks but this simply won't work like this as I am using all filters and almost all filters (wrong word probably) e.g. brightness, contrast etc which is the whole point of my request. Tracking state is tricky. Not impossible, I'm doing it now, but, its much more complex than I'd like – StudioTime Jun 10 '13 at 14:18
  • Couldn't you just call a function that caches each setting, then re-apply (register?) these settings + your new tweaks to the same image? – PHearst Jun 16 '13 at 10:38
0

If i understand you correctly , You want to apply a filter and play with other effects like brightness and contrast etc.,
I made some code which will work according to your need

 Caman('#canvas-camanImage',"./../media/caman.png", function () {
        this.revert(false);
        for(var i = 0 ;i<selectedPresets.length;i++){
            this[selectedPresets[i]]();
        }
        for(var key in effect){
            this[key](effect[key].value);
        }
        this.render(function () {
        });

in the above code i am storing all effects like brightness contrast in effect variable like effect = { brightness : { min : -100, max: 100, value : 0 }, contrast : { min : -100, max: 100, value : 0 }, saturation : { min : -100, max: 100, value : 0 } };

and presets in an array

presets = [
    {filter:'vintage',name : 'Vintage'},
    {filter:'lomo',name:'Lomo'},
    {filter: 'clarity', name:'Clarity'},
    {filter:'sinCity', name:'Sin City'}
    ];

So every time you add any preset or change any effect value i am changing the values in variable and rendering canvas again
It is working very fine for me
Let me know if your concern is something else

Aravind Reddy
  • 747
  • 6
  • 20