jimp-dev/jimp

I tried to add instagram filters from this code

Aberta

#1.015 aberto em 19 de mai. de 2021

 (1 comentário) (0 reação) (0 responsável)JavaScript (785 forks)batch import
enhancementhelp wanted

Métricas do repositório

Stars
 (13.218 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Hi I tried these instagram filter from this source code

https://github.com/girliemac/filterous-2/blob/master/lib/instaFilters.js#L135

I think you need to add these two function

	rgbAdjust: function rgbAdjust(rgbAdj,cb) {
		this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
			var red = this.bitmap.data[idx];
			var green = this.bitmap.data[idx + 1];
			var blue = this.bitmap.data[idx + 2];
			red *= rgbAdj[0]
			green *= rgbAdj[1]
			blue *= rgbAdj[2]
			this.bitmap.data[idx] = red < 255 ? red : 255;
			this.bitmap.data[idx + 1] = green < 255 ? green : 255;
			this.bitmap.data[idx + 2] = blue < 255 ? blue : 255;
		});

		if ((0, _utils.isNodePattern)(cb)) {
			cb.call(this, null, this);
		}

		return this;
	},

and

colorFilter: function colorFilter(rgbColor,cb) {
  this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
    var adj = rgbColor[3];
    var red = this.bitmap.data[idx];
    var green = this.bitmap.data[idx + 1];
    var blue = this.bitmap.data[idx + 2];
    red -= (red - rgbColor[0]) * adj;
    green  -= (green - rgbColor[1]) * adj;
    blue -= (blue - rgbColor[2]) * adj;
    this.bitmap.data[idx] = red < 255 ? red : 255;
    this.bitmap.data[idx + 1] = green < 255 ? green : 255;
    this.bitmap.data[idx + 2] = blue < 255 ? blue : 255;
  });

  if ((0, _utils.isNodePattern)(cb)) {
    cb.call(this, null, this);
  }

  return this;
},

in plugin color, it's help shorten image manipulation. and in sepia color filterous-2 has value to change sepia intensity

Guia do colaborador