A set of fixes to keep resized image state properly#163
A set of fixes to keep resized image state properly#163zaak wants to merge 12 commits intomeltingice:masterfrom
Conversation
|
You're a legend mate! Thank you so much. |
|
It seems that the |
|
@zaak It would be such a great christmas present... sharing caman.full.js with the fixes to keep resized image state properly with all of us. Please? |
|
Hey @av01d. Sorry, I didn't notice your previous message. |
|
Thanks @zaak for this nice christmas gift ;-) |
|
As for the non-working And when I wanted to revert that filter: This last call calls the Caman constructor again, re-initializing the image in #filterImg. The correct approach (for both the original caman.full.js and the version made by @zaak) is this: And if you want to revert a filter, do this: You now have only 1 Caman instance, its constructor is called only once and everything works! |
There was a few issues related to keeping image state after any of the resizing tranformations (like resize, crop, rotate). The
revertmethod worked improperly in this case, applying only one transformation on original pixel data. This logic failed if image was modified more that once (for example crop, then rotate, then resize etc).What I did was just simply adding an additional canvas especially for rendering. Resized image state is kept by an internal canvas (with all modifications like crop, resize, rotate, but without any filters applied), so there are always "fresh" pixels ready for use in
revert. The second canvas (visible one) is used for rendering - it takes image from first canvas and applies filters/presets to create the final image.Also merged plugins submodule, updated conflicting node packages and fixed build scripts for travis.
Small demo: http://zaak.github.io/CamanJS-demo/