CamanJS

2023-06-18

前端

过分宽大的法律,不易使人服从;太严厉的法律,则绝少被遵守。——富兰克林

分享一个前端基于canvas的图片js

http://camanjs.com/

https://github.com/meltingice/CamanJS

安装

1
npm install caman

用法:

1
2
3
4
5
6
7
Caman('#my-image', function () {
this.brightness(10);
this.contrast(30);
this.sepia(60);
this.saturation(-30);
this.render();
});

html

1
2
3
4
5
<img 
data-caman="brightness(10) contrast(30) sepia(60) saturation(-30)"
data-caman-hidpi="/path/to/image@2x.jpg"
src="path/to/image.jpg"
>

image-20230618223055026